1
0
Fork 0

Merge pull request #9645 from MrPetovan/bug/fatal-errors

Normalize return value in Database->fetch
This commit is contained in:
Tobias Diekershoff 2020-12-10 14:05:03 +01:00 committed by GitHub
commit 6e7fe32953
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View file

@ -910,13 +910,12 @@ class Database
/**
* Fetch a single row
*
* @param mixed $stmt statement object
* @param PDOStatement|mysqli_stmt $stmt statement object
*
* @return array current row
* @return array|false current row
*/
public function fetch($stmt)
{
$stamp1 = microtime(true);
$columns = [];
@ -934,7 +933,7 @@ class Database
break;
case self::MYSQLI:
if (get_class($stmt) == 'mysqli_result') {
$columns = $stmt->fetch_assoc();
$columns = $stmt->fetch_assoc() ?? false;
break;
}

View file

@ -223,13 +223,14 @@ class Item
* Fetch a single item row
*
* @param mixed $stmt statement object
* @return array current row
* @return array|false current row or false
* @throws \Exception
*/
public static function fetch($stmt)
{
$row = DBA::fetch($stmt);
if (is_bool($row)) {
if (!is_array($row)) {
return $row;
}