From 89a085a12c031721de1a5ab4f757d94ada590f63 Mon Sep 17 00:00:00 2001 From: Philipp Date: Mon, 13 Sep 2021 20:31:14 +0200 Subject: [PATCH] Check DBA::count() result --- src/Database/Database.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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']; + } } /**