summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2017-04-18 08:36:29 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2017-04-18 08:40:22 +0200
commit4f662c773dd70145640074f2659954e8f8a3daef (patch)
treed646b65155088d328eb2eb316b185a277273c52f /web/lib
parent6090c2ae8b6b33af79cae2ed63ebe5209d0729b3 (diff)
downloadaur-4f662c773dd70145640074f2659954e8f8a3daef.tar.gz
aur-4f662c773dd70145640074f2659954e8f8a3daef.tar.xz
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 <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/cachefuncs.inc.php3
1 files changed, 3 insertions, 0 deletions
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);