[PATCH] Handle empty resultset getting recent 10 packages
--- web/lib/stats.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/lib/stats.inc.php b/web/lib/stats.inc.php index 80619fe..f5692f9 100644 --- a/web/lib/stats.inc.php +++ b/web/lib/stats.inc.php @@ -19,10 +19,12 @@ function updates_table() { $result = $dbh->query($q); $newest_packages = new ArrayObject(); - while ($row = $result->fetch(PDO::FETCH_ASSOC)) { - $newest_packages->append($row); + if ($result) { + while ($row = $result->fetch(PDO::FETCH_ASSOC)) { + $newest_packages->append($row); + } + set_cache_value($key, $newest_packages); } - set_cache_value($key, $newest_packages); } include('stats/updates_table.php'); } -- 2.16.1
Replaced spaces w/ tabs in this version On Tue, Mar 20, 2018 at 8:47 PM, nodivbyzero <nodivbyzero@gmail.com> wrote:
--- web/lib/stats.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/web/lib/stats.inc.php b/web/lib/stats.inc.php index 80619fe..f5692f9 100644 --- a/web/lib/stats.inc.php +++ b/web/lib/stats.inc.php @@ -19,10 +19,12 @@ function updates_table() { $result = $dbh->query($q);
$newest_packages = new ArrayObject(); - while ($row = $result->fetch(PDO::FETCH_ASSOC)) { - $newest_packages->append($row); + if ($result) { + while ($row = $result->fetch(PDO::FETCH_ASSOC)) { + $newest_packages->append($row); + } + set_cache_value($key, $newest_packages); } - set_cache_value($key, $newest_packages); } include('stats/updates_table.php'); } -- 2.16.1
On Tue, 20 Mar 2018 at 21:47:44, nodivbyzero wrote:
--- web/lib/stats.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) [...]
Merged, thanks!
participants (3)
-
Lukas Fleischer
-
Nodiv Byzero
-
nodivbyzero