From 8053afeb2289ff1c88b95dc52361f4e4379f0fc1 Mon Sep 17 00:00:00 2001 From: Cecilia Vela Gurovic Date: Thu, 1 Nov 2018 14:01:13 +1300 Subject: [PATCH] Bug 1800961: php foreach should only be used on arrays trying to use any other type of variable will throw an exception. Also, block types and view types should not be nested in the template behatnotneeded Change-Id: I1ea1e3fc9e7ba7734e1b5712467678c001806e65 (cherry picked from commit b7c588549b6da9eca1632974ea0c5bc42b26451f) --- htdocs/lib/statistics.php | 10 ++++++---- htdocs/theme/raw/templates/admin/viewstatssummary.tpl | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/lib/statistics.php b/htdocs/lib/statistics.php index 6527cdb4e3..b09bc62f2b 100644 --- a/htdocs/lib/statistics.php +++ b/htdocs/lib/statistics.php @@ -206,10 +206,12 @@ function site_statistics($full=false) { ORDER BY blocks DESC", array(), 0, $maxblocktypes ); - foreach ($blocktypecounts as $blocktype) { - safe_require('blocktype', $blocktype->blocktype); - $classname = generate_class_name('blocktype', $blocktype->blocktype); - $blocktype->title = $classname::get_title(); + if (is_array($blocktypecounts)) { + foreach ($blocktypecounts as $blocktype) { + safe_require('blocktype', $blocktype->blocktype); + $classname = generate_class_name('blocktype', $blocktype->blocktype); + $blocktype->title = $classname::get_title(); + } } $smarty->assign('blocktypecounts', $blocktypecounts); diff --git a/htdocs/theme/raw/templates/admin/viewstatssummary.tpl b/htdocs/theme/raw/templates/admin/viewstatssummary.tpl index ef79c142ac..18ec9316ca 100644 --- a/htdocs/theme/raw/templates/admin/viewstatssummary.tpl +++ b/htdocs/theme/raw/templates/admin/viewstatssummary.tpl @@ -8,7 +8,8 @@
  • {$item->title}: {$item->blocks}
  • {/foreach} - {if $viewtypes} +{/if} +{if $viewtypes}

    {str tag=viewsbytype section=admin}

    @@ -20,5 +21,4 @@ {/literal}
    - {/if} {/if} -- GitLab