Commit 5ca1e271 authored by Eli Schwartz's avatar Eli Schwartz Committed by Lukas Fleischer
Browse files

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's avatarEli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer's avatarLukas Fleischer <lfleischer@archlinux.org>
parent 65c98d12
...@@ -197,7 +197,9 @@ function username_from_id($id) { ...@@ -197,7 +197,9 @@ function username_from_id($id) {
} }
$row = $result->fetch(PDO::FETCH_NUM); $row = $result->fetch(PDO::FETCH_NUM);
if ($row) {
return $row[0]; return $row[0];
}
} }
/** /**
...@@ -222,7 +224,9 @@ function username_from_sid($sid="") { ...@@ -222,7 +224,9 @@ function username_from_sid($sid="") {
} }
$row = $result->fetch(PDO::FETCH_NUM); $row = $result->fetch(PDO::FETCH_NUM);
if ($row) {
return $row[0]; return $row[0];
}
} }
/** /**
...@@ -339,7 +343,9 @@ function email_from_sid($sid="") { ...@@ -339,7 +343,9 @@ function email_from_sid($sid="") {
} }
$row = $result->fetch(PDO::FETCH_NUM); $row = $result->fetch(PDO::FETCH_NUM);
if ($row) {
return $row[0]; return $row[0];
}
} }
/** /**
...@@ -365,7 +371,9 @@ function account_from_sid($sid="") { ...@@ -365,7 +371,9 @@ function account_from_sid($sid="") {
} }
$row = $result->fetch(PDO::FETCH_NUM); $row = $result->fetch(PDO::FETCH_NUM);
if ($row) {
return $row[0]; return $row[0];
}
} }
/** /**
...@@ -390,7 +398,9 @@ function uid_from_sid($sid="") { ...@@ -390,7 +398,9 @@ function uid_from_sid($sid="") {
} }
$row = $result->fetch(PDO::FETCH_NUM); $row = $result->fetch(PDO::FETCH_NUM);
if ($row) {
return $row[0]; return $row[0];
}
} }
/** /**
...@@ -512,7 +522,9 @@ function uid_from_username($username) { ...@@ -512,7 +522,9 @@ function uid_from_username($username) {
} }
$row = $result->fetch(PDO::FETCH_NUM); $row = $result->fetch(PDO::FETCH_NUM);
if ($row) {
return $row[0]; return $row[0];
}
} }
/** /**
...@@ -546,7 +558,9 @@ function uid_from_email($email) { ...@@ -546,7 +558,9 @@ function uid_from_email($email) {
} }
$row = $result->fetch(PDO::FETCH_NUM); $row = $result->fetch(PDO::FETCH_NUM);
if ($row) {
return $row[0]; return $row[0];
}
} }
/** /**
......
...@@ -147,7 +147,9 @@ function pkg_from_name($name="") { ...@@ -147,7 +147,9 @@ function pkg_from_name($name="") {
return; return;
} }
$row = $result->fetch(PDO::FETCH_NUM); $row = $result->fetch(PDO::FETCH_NUM);
if ($row) {
return $row[0]; return $row[0];
}
} }
/** /**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment