From 9b3e36e25f53f3db81f5d643abdc00eec285d148 Mon Sep 17 00:00:00 2001 From: Robert Lyon Date: Wed, 23 Jan 2019 09:09:33 +1300 Subject: [PATCH] Bug 1812910: Importer needs to use is_array() before count() in PHP 7.2 When we are wanting to check if there is an array to foreach loop over and that array has at least one entry. Currently we try to loop over entries by checking with just count() and we get error - count(): Parameter must be an array or an object that implements Countable behatnotneeded Change-Id: I9accca2e97f415d5f9a2203b6fd984a41e95a4d0 Signed-off-by: Robert Lyon --- .../artefact/annotation/templates/import/annotations.tpl | 2 +- .../raw/plugintype/artefact/file/templates/import/files.tpl | 2 +- .../artefact/internal/templates/import/profilefields.tpl | 4 ++-- .../artefact/peerassessment/templates/import/assessments.tpl | 2 +- .../artefact/resume/templates/import/resumefields.tpl | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/theme/raw/plugintype/artefact/annotation/templates/import/annotations.tpl b/htdocs/theme/raw/plugintype/artefact/annotation/templates/import/annotations.tpl index 61a5997abb..ff4d739c27 100644 --- a/htdocs/theme/raw/plugintype/artefact/annotation/templates/import/annotations.tpl +++ b/htdocs/theme/raw/plugintype/artefact/annotation/templates/import/annotations.tpl @@ -1,4 +1,4 @@ -{if count($entryannotations)} +{if is_array($entryannotations) && count($entryannotations)}

{str tag=Annotation section=artefact.annotation}

{foreach from=$entryannotations item=annotation} diff --git a/htdocs/theme/raw/plugintype/artefact/file/templates/import/files.tpl b/htdocs/theme/raw/plugintype/artefact/file/templates/import/files.tpl index d9ecdd0998..a55d93fadb 100644 --- a/htdocs/theme/raw/plugintype/artefact/file/templates/import/files.tpl +++ b/htdocs/theme/raw/plugintype/artefact/file/templates/import/files.tpl @@ -1,4 +1,4 @@ -{if count($entryfiles)} +{if is_array($entryfiles) && count($entryfiles)}

{str tag=file section=artefact.file}

{foreach from=$entryfiles item=file} diff --git a/htdocs/theme/raw/plugintype/artefact/internal/templates/import/profilefields.tpl b/htdocs/theme/raw/plugintype/artefact/internal/templates/import/profilefields.tpl index cf0f677a3e..19d932361f 100644 --- a/htdocs/theme/raw/plugintype/artefact/internal/templates/import/profilefields.tpl +++ b/htdocs/theme/raw/plugintype/artefact/internal/templates/import/profilefields.tpl @@ -2,7 +2,7 @@

{str tag=profile section=artefact.internal}

{foreach from=$profilegroups item=profilegroup name='profilegroup'} - {if count($profilegroup.fields)} + {if is_array($profilegroup.fields) && count($profilegroup.fields)}

@@ -14,7 +14,7 @@
{foreach from=$profilegroup.fields key=fieldname item=fieldvalues} - {if count($fieldvalues)} + {if is_array($fieldvalues) && count($fieldvalues)}
{str tag=$fieldname section=artefact.internal} diff --git a/htdocs/theme/raw/plugintype/artefact/peerassessment/templates/import/assessments.tpl b/htdocs/theme/raw/plugintype/artefact/peerassessment/templates/import/assessments.tpl index 4314716226..4b6897228a 100644 --- a/htdocs/theme/raw/plugintype/artefact/peerassessment/templates/import/assessments.tpl +++ b/htdocs/theme/raw/plugintype/artefact/peerassessment/templates/import/assessments.tpl @@ -1,4 +1,4 @@ -{if count($entrypeerassessments)} +{if is_array($entrypeerassessments) && count($entrypeerassessments)}

{str tag=peerassessment section=artefact.peerassessment}

{foreach from=$entrypeerassessments item=peerassessment} diff --git a/htdocs/theme/raw/plugintype/artefact/resume/templates/import/resumefields.tpl b/htdocs/theme/raw/plugintype/artefact/resume/templates/import/resumefields.tpl index ed4c6ffad4..667ce6e9ff 100644 --- a/htdocs/theme/raw/plugintype/artefact/resume/templates/import/resumefields.tpl +++ b/htdocs/theme/raw/plugintype/artefact/resume/templates/import/resumefields.tpl @@ -2,7 +2,7 @@

{str tag=resume section=artefact.resume}

{foreach from=$resumegroups item=resumegroup} - {if count($resumegroup.fields)} + {if is_array($resumegroup.fields) && count($resumegroup.fields)}

@@ -14,7 +14,7 @@
{foreach from=$resumegroup.fields key=fieldname item=fieldvalues} - {if count(fieldvalues)} + {if is_array($fieldvalues) && count($fieldvalues)}
{$fieldname} -- GitLab