[PATCH] Handle empty resultset getting recent 10 packages
Nodiv Byzero
nodivbyzero at gmail.com
Wed Mar 21 03:37:25 UTC 2018
It renders incorrectly main page(Statistics) with empty database.
On Tue, Mar 20, 2018 at 8:33 PM, nodivbyzero <nodivbyzero at gmail.com> wrote:
> ---
> web/lib/stats.inc.php | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/web/lib/stats.inc.php b/web/lib/stats.inc.php
> index 80619fe..0fa3ec6 100644
> --- a/web/lib/stats.inc.php
> +++ b/web/lib/stats.inc.php
> @@ -19,10 +19,13 @@ function updates_table() {
> $result = $dbh->query($q);
>
> $newest_packages = new ArrayObject();
> - while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
> - $newest_packages->append($row);
> - }
> - set_cache_value($key, $newest_packages);
> + if ($result) {
> +
> + while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
> + $newest_packages->append($row);
> + }
> + set_cache_value($key, $newest_packages);
> + }
> }
> include('stats/updates_table.php');
> }
> --
> 2.16.1
>
More information about the aur-dev
mailing list