Normalize return value in Database->fetch
- Address https://github.com/friendica/friendica/issues/9250#issuecomment-741857058
This commit is contained in:
parent
675f54e44f
commit
99b200868b
|
@ -910,13 +910,12 @@ class Database
|
||||||
/**
|
/**
|
||||||
* Fetch a single row
|
* 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)
|
public function fetch($stmt)
|
||||||
{
|
{
|
||||||
|
|
||||||
$stamp1 = microtime(true);
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
$columns = [];
|
$columns = [];
|
||||||
|
@ -934,7 +933,7 @@ class Database
|
||||||
break;
|
break;
|
||||||
case self::MYSQLI:
|
case self::MYSQLI:
|
||||||
if (get_class($stmt) == 'mysqli_result') {
|
if (get_class($stmt) == 'mysqli_result') {
|
||||||
$columns = $stmt->fetch_assoc();
|
$columns = $stmt->fetch_assoc() ?? false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,13 +223,14 @@ class Item
|
||||||
* Fetch a single item row
|
* Fetch a single item row
|
||||||
*
|
*
|
||||||
* @param mixed $stmt statement object
|
* @param mixed $stmt statement object
|
||||||
* @return array current row
|
* @return array|false current row or false
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function fetch($stmt)
|
public static function fetch($stmt)
|
||||||
{
|
{
|
||||||
$row = DBA::fetch($stmt);
|
$row = DBA::fetch($stmt);
|
||||||
|
|
||||||
if (is_bool($row)) {
|
if (!is_array($row)) {
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue