From 4f662c773dd70145640074f2659954e8f8a3daef Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Tue, 18 Apr 2017 08:36:29 +0200 Subject: Check query return value in db_cache_value() Instead of unconditionally calling fetch on the return value of query(), error out early if the value evaluates to false. Signed-off-by: Lukas Fleischer --- web/lib/cachefuncs.inc.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'web') diff --git a/web/lib/cachefuncs.inc.php b/web/lib/cachefuncs.inc.php index d558be44..faeae5a2 100644 --- a/web/lib/cachefuncs.inc.php +++ b/web/lib/cachefuncs.inc.php @@ -73,6 +73,9 @@ function db_cache_value($dbq, $key, $ttl=600) { $value = get_cache_value($key, $status); if (!$status) { $result = $dbh->query($dbq); + if (!$result) { + return false; + } $row = $result->fetch(PDO::FETCH_NUM); $value = $row[0]; set_cache_value($key, $value, $ttl); -- cgit v1.2.3-24-g4f1b