Check DBA::count() result

This commit is contained in:
Philipp 2021-09-13 20:31:14 +02:00
parent 644f312896
commit 89a085a12c
No known key found for this signature in database
GPG key ID: 24A7501396EB5432

View file

@ -1461,9 +1461,14 @@ class Database
$row = $this->fetchFirst($sql, $condition);
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'];
}
}
/**
* Fills an array with data from a query