From: Philipp Date: Mon, 13 Sep 2021 18:31:14 +0000 (+0200) Subject: Check DBA::count() result X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=89a085a12c031721de1a5ab4f757d94ada590f63;p=friendica.git Check DBA::count() result --- diff --git a/src/Database/Database.php b/src/Database/Database.php index 361a3248d9..c11e04936b 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -1461,8 +1461,13 @@ class Database $row = $this->fetchFirst($sql, $condition); - // Ensure to always return either a "null" or a numeric value - return is_numeric($row['count']) ? (int)$row['count'] : $row['count']; + if (empty($row['count'])) { + $this->logger->notice('Invalid count.', ['table' => $table, 'expression' => $expression, 'condition' => $condition_string]); + return 0; + } else { + // Ensure to always return either a "null" or a numeric value + return is_numeric($row['count']) ? (int)$row['count'] : $row['count']; + } } /**