]> git.mxchange.org Git - friendica.git/commitdiff
Check DBA::count() result
authorPhilipp <admin@philipp.info>
Mon, 13 Sep 2021 18:31:14 +0000 (20:31 +0200)
committerPhilipp <admin@philipp.info>
Sat, 18 Sep 2021 10:51:08 +0000 (12:51 +0200)
src/Database/Database.php

index 361a3248d9ce40a00b518fed988072108ef4ae20..c11e04936b26f83664627fa721ad0baad0f316df 100644 (file)
@@ -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'];
+               }
        }
 
        /**