From 659391a4c3d29d312d2815ad2b885d01ac4e2191 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 14 Jul 2017 10:39:54 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#316 - legacy db API variable class and debug timers in PHP7 producing unnecessary notice --- wire/core/Database.php | 6 +++--- wire/core/Debug.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wire/core/Database.php b/wire/core/Database.php index 9f5aac2f..6636d969 100644 --- a/wire/core/Database.php +++ b/wire/core/Database.php @@ -104,7 +104,7 @@ class Database extends \mysqli implements WireDatabase { if($this->debug) { $timerKey = Debug::timer(); - if(!$timerFirstStartTime) $timerFirstStartTime = $timerKey; + if(!$timerFirstStartTime) $timerFirstStartTime = (float) $timerKey; } else $timerKey = null; $result = @parent::query($sql, $resultmode); @@ -113,9 +113,9 @@ class Database extends \mysqli implements WireDatabase { if($this->debug) { if(isset($result->num_rows)) $sql .= " [" . $result->num_rows . " rows]"; if(!is_null($timerKey)) { - $elapsed = Debug::timer($timerKey); + $elapsed = (float) Debug::timer($timerKey); $timerTotalQueryTime += $elapsed; - $timerTotalSinceStart = Debug::timer() - $timerFirstStartTime; + $timerTotalSinceStart = ((float) Debug::timer()) - $timerFirstStartTime; $sql .= " [{$elapsed}s, {$timerTotalQueryTime}s, {$timerTotalSinceStart}s]"; } $this->queryLog($sql); diff --git a/wire/core/Debug.php b/wire/core/Debug.php index 38cf09be..cc3b72ec 100644 --- a/wire/core/Debug.php +++ b/wire/core/Debug.php @@ -66,7 +66,7 @@ class Debug { $startTime = -microtime(true); if(!$key) { $key = (string) $startTime; - while(isset(self::$timers[$key])) $key .= "."; + while(isset(self::$timers[$key])) $key .= "0"; } self::$timers[(string) $key] = $startTime; $value = $key;