mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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>
This commit is contained in:
parent
6090c2ae8b
commit
4f662c773d
1 changed files with 3 additions and 0 deletions
|
@ -73,6 +73,9 @@ function db_cache_value($dbq, $key, $ttl=600) {
|
||||||
$value = get_cache_value($key, $status);
|
$value = get_cache_value($key, $status);
|
||||||
if (!$status) {
|
if (!$status) {
|
||||||
$result = $dbh->query($dbq);
|
$result = $dbh->query($dbq);
|
||||||
|
if (!$result) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$row = $result->fetch(PDO::FETCH_NUM);
|
$row = $result->fetch(PDO::FETCH_NUM);
|
||||||
$value = $row[0];
|
$value = $row[0];
|
||||||
set_cache_value($key, $value, $ttl);
|
set_cache_value($key, $value, $ttl);
|
||||||
|
|
Loading…
Add table
Reference in a new issue