diff --git a/php/libraries/Database.class.inc b/php/libraries/Database.class.inc index b5aaaf98d8d..22b79bfd024 100644 --- a/php/libraries/Database.class.inc +++ b/php/libraries/Database.class.inc @@ -635,6 +635,13 @@ class Database } $rows = $prepared->fetchAll(PDO::FETCH_ASSOC); + // The fetchAll function will return an empty set if no results are + // found and FALSE on "failure". We don't expect this case so an + // exception is thrown. + if (is_bool($rows) && $rows === false) { + $err = $prepared->errorInfo(); + throw new DatabaseException($err[2], $prepared->queryString, $params); + } return $rows; } /**