From 90084efd75ec2cdb5ad356c32fb93b4950111abe Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Fri, 30 Oct 2020 23:14:08 +0900 Subject: [PATCH] Fix undefined indices and incompatible function signatures --- common/framework/debug.php | 6 +++--- common/framework/helpers/dbhelper.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/framework/debug.php b/common/framework/debug.php index 65c584bd6..c44e602b8 100644 --- a/common/framework/debug.php +++ b/common/framework/debug.php @@ -304,7 +304,7 @@ class Debug * @param array $errcontext * @return void */ - public static function addError($errno, $errstr, $errfile, $errline, $errcontext) + public static function addError($errno, $errstr, $errfile, $errline, $errcontext = []) { // Do not store log if disabled. if (!self::$_enabled) @@ -597,10 +597,10 @@ class Debug foreach ($backtrace as $step) { $stepstr = '#' . count($result) . ' '; - $stepstr .= $step['file'] . '(' . $step['line'] . ')'; + $stepstr .= ($step['file'] ?? 'unknown') . '(' . ($step['line'] ?? 0) . ')'; if ($step['function']) { - $stepstr .= ': ' . ($step['type'] ? ($step['class'] . $step['type'] . $step['function']) : $step['function']) . '()'; + $stepstr .= ': ' . ((isset($step['type']) && $step['type']) ? ($step['class'] . $step['type'] . $step['function']) : $step['function']) . '()'; } $result[] = strtr($stepstr, "\0\r\n\t\v\e\f", ' '); } diff --git a/common/framework/helpers/dbhelper.php b/common/framework/helpers/dbhelper.php index 100f9e701..17a67a0ae 100644 --- a/common/framework/helpers/dbhelper.php +++ b/common/framework/helpers/dbhelper.php @@ -83,7 +83,7 @@ class DBHelper extends \PDO * @param string $statement * @return PDOStatement|DBStmtHelper */ - public function query($statement) + public function query($statement, $fetch_mode = \PDO::FETCH_OBJ, ...$fetch_mode_args) { $start_time = microtime(true); $db_class = DB::getInstance($this->_type); @@ -98,7 +98,7 @@ class DBHelper extends \PDO * and send query logs to the appropriate place. */ $stmt = parent::query($statement, ...$args); - $stmt->setFetchMode(\PDO::FETCH_OBJ); + $stmt->setFetchMode($fetch_mode); $stmt->setType($this->_type); $db_class->clearError(); }