Fix PHP 7.4 warnings

If a db query returned NULL instead of an array, then accessing $row[0]
now throws a warning. The undocumented behavior of evaluating to NULL
is maintained, and we want to return NULL anyway, so add a check for the
value and fall back on the default function return type.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Eli Schwartz 2020-02-12 15:16:37 -05:00 committed by Lukas Fleischer
parent 65c98d1216
commit 5ca1e271f9
2 changed files with 24 additions and 8 deletions

View file

@ -147,7 +147,9 @@ function pkg_from_name($name="") {
return;
}
$row = $result->fetch(PDO::FETCH_NUM);
return $row[0];
if ($row) {
return $row[0];
}
}
/**