Commit 09d05944 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1812910: Needs to use is_array() before count() in PHP 7.2



Fixing up some more places, like elasticsearch results, where we are
trying to get a cound on a variable that is not an array

behatnotneeded

Change-Id: I09b809240f18892a187c5e5ed2a3d1756e39b247
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit ef57506f)
parent 1261963a
...@@ -59,7 +59,7 @@ $smarty = smarty(array('adminusersearch', 'adminexportqueue','paginator'), array ...@@ -59,7 +59,7 @@ $smarty = smarty(array('adminusersearch', 'adminexportqueue','paginator'), array
setpageicon($smarty, 'icon-users'); setpageicon($smarty, 'icon-users');
$smarty->assign('search', $search); $smarty->assign('search', $search);
$smarty->assign('limit', $limit); $smarty->assign('limit', $limit);
$smarty->assign('institutions', $institutions); $smarty->assign('institutions', !empty($institutions) ? $institutions : array());
$smarty->assign('results', $html); $smarty->assign('results', $html);
$smarty->assign('pagination', $pagination['html']); $smarty->assign('pagination', $pagination['html']);
$smarty->assign('columns', $columns); $smarty->assign('columns', $columns);
......
...@@ -34,6 +34,7 @@ $MANDATORYFIELDS = array( ...@@ -34,6 +34,7 @@ $MANDATORYFIELDS = array(
); );
$MEMBERS = array(); // Store the members $MEMBERS = array(); // Store the members
$GROUPS = array(); // Map gid to group shortnames $GROUPS = array(); // Map gid to group shortnames
$UPDATES = array(); // During validation, remember which group already exist
$form = array( $form = array(
'name' => 'uploadcsv', 'name' => 'uploadcsv',
......
...@@ -46,6 +46,10 @@ $users = get_records_sql_assoc(' ...@@ -46,6 +46,10 @@ $users = get_records_sql_assoc('
$ph $ph
); );
if (empty($users)) {
// None of the userids are valid
throw new InvalidArgumentException("Trying to access invalid user(s)");
}
// Display the number of users filtered out due to institution permissions. This is not an // Display the number of users filtered out due to institution permissions. This is not an
// exception, because the logged in user might be an admin in one institution, and staff in // exception, because the logged in user might be an admin in one institution, and staff in
// another. // another.
......
...@@ -167,7 +167,7 @@ $smarty = smarty(array('adminexportqueue', 'paginator'), array(), array('ascendi ...@@ -167,7 +167,7 @@ $smarty = smarty(array('adminexportqueue', 'paginator'), array(), array('ascendi
setpageicon($smarty, 'icon-user'); setpageicon($smarty, 'icon-user');
$smarty->assign('search', $search); $smarty->assign('search', $search);
$smarty->assign('limit', $limit); $smarty->assign('limit', $limit);
$smarty->assign('institutions', $institutions); $smarty->assign('institutions', !empty($institutions) ? $institutions : array());
$smarty->assign('results', $html); $smarty->assign('results', $html);
$smarty->assign('pagination', $pagination['html']); $smarty->assign('pagination', $pagination['html']);
$smarty->assign('columns', $columns); $smarty->assign('columns', $columns);
......
...@@ -3,28 +3,28 @@ ...@@ -3,28 +3,28 @@
{if $icon}<div id="profile-icon">{$icon|safe}</div>{/if} {if $icon}<div id="profile-icon">{$icon|safe}</div>{/if}
{foreach from=$sections key=sectionname item=section} {foreach from=$sections key=sectionname item=section}
{if count($section)} {if is_array($section) && count($section)}
<div class="profileinfo"> <div class="profileinfo">
<h3>{str tag=$sectionname section=artefact.internal}</h3> <h3>{str tag=$sectionname section=artefact.internal}</h3>
<table> <table>
{foreach from=$section key=title item=value} {foreach from=$section key=title item=value}
{if $title == 'socialprofile'} {if $title == 'socialprofile'}
{foreach from=$value item=profile} {foreach from=$value item=profile}
<tr> <tr>
<th>{$profile.label|safe}:</th> <th>{$profile.label|safe}:</th>
<td>{$profile.link|safe}</td> <td>{$profile.link|safe}</td>
</tr> </tr>
{/foreach} {/foreach}
{else} {else}
<tr> <tr>
<th>{str tag=$title section=artefact.internal}:</th> <th>{str tag=$title section=artefact.internal}:</th>
<td>{$value|safe}</td> <td>{$value|safe}</td>
</tr> </tr>
{/if}
{/foreach}
</table>
</div>
{/if} {/if}
{/foreach}
</table>
</div>
{/if}
{/foreach} {/foreach}
{include file="export:html:footer.tpl"} {include file="export:html:footer.tpl"}
...@@ -111,14 +111,14 @@ ...@@ -111,14 +111,14 @@
</option> </option>
{/if} {/if}
{if $moderator && $otherforums && (count($otherforums) > 0)} {if $moderator && !empty($otherforums) && (count($otherforums) > 0)}
<option value="moveto"> <option value="moveto">
{str tag="Moveto" section="interaction.forum"} {str tag="Moveto" section="interaction.forum"}
</option> </option>
{/if} {/if}
</select> </select>
{if $moderator && $otherforums && (count($otherforums) > 0)} {if $moderator && !empty($otherforums) && (count($otherforums) > 0)}
<select name="newforum" id="otherforums" class="hidden form-control select"> <select name="newforum" id="otherforums" class="hidden form-control select">
{foreach from=$otherforums item=otherforum} {foreach from=$otherforums item=otherforum}
<option value="{$otherforum->id}"> <option value="{$otherforum->id}">
......
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
{str section='module.multirecipientnotification' tag='touser'}: {str section='module.multirecipientnotification' tag='touser'}:
</span> </span>
<span class="username"> <span class="username">
{if count($item->tousr) > 0} {if is_array($item->tousr) && count($item->tousr) > 0}
{assign var="tousr" value=$item->tousr[0]} {assign var="tousr" value=$item->tousr[0]}
{if count($tousr['username']) > 0} {if is_array($tousr['username']) && count($tousr['username']) > 0}
{$tousr['username']|truncate:$maxnamestrlength} {$tousr['username']|truncate:$maxnamestrlength}
{else} {else}
{$tousr['display']|truncate:$maxnamestrlength} {$tousr['display']|truncate:$maxnamestrlength}
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<strong> <strong>
{str section='module.multirecipientnotification' tag='touser'}: {str section='module.multirecipientnotification' tag='touser'}:
</strong> </strong>
{if count($item->tousr) > 1} {if is_array($item->tousr) && count($item->tousr) > 1}
<span> <span>
{foreach from=$item->tousr item=tousr key=break} {foreach from=$item->tousr item=tousr key=break}
{if ($tousr['link'])}<a href="{$tousr['link']}">{/if} {if ($tousr['link'])}<a href="{$tousr['link']}">{/if}
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
{/if} {/if}
</div> </div>
<!-- TAGS --> <!-- TAGS -->
{if $record->tags|count gt 0} {if is_array($record->tags) && count($record->tags) > 0}
<div class="tags"><strong>{str tag=tags section=search.elasticsearch}:</strong> <div class="tags"><strong>{str tag=tags section=search.elasticsearch}:</strong>
{foreach from=$record->tags item=tag name=tags} {foreach from=$record->tags item=tag name=tags}
<a href="{$WWWROOT}search/elasticsearch/index.php?query={$tag}&tagsonly=true">{$tag}</a>{if !$.foreach.tags.last}, {/if} <a href="{$WWWROOT}search/elasticsearch/index.php?query={$tag}&tagsonly=true">{$tag}</a>{if !$.foreach.tags.last}, {/if}
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
</div> </div>
<!-- RESUMEITEMS --> <!-- RESUMEITEMS -->
<div class="col-md-4"> <div class="col-md-4">
{if $record->resumeitems|count gt 0} {if is_array($record->resumeitems) && count($record->resumeitems) > 0}
<strong>{str tag=contains section=search.elasticsearch}:</strong> <strong>{str tag=contains section=search.elasticsearch}:</strong>
<ul> <ul>
{foreach from=$record->resumeitems key=rid item=resume} {foreach from=$record->resumeitems key=rid item=resume}
...@@ -85,9 +85,9 @@ ...@@ -85,9 +85,9 @@
{/if} {/if}
<!-- VIEWS --> <!-- VIEWS -->
{if $record->views|count gt 0} {if is_array($record->views) && count($record->views) > 0}
<div class="usedon"> <div class="usedon">
{if $record->views|count gt 1} {if count($record->views) > 1}
<strong>{str tag=usedonpages section=search.elasticsearch}:</strong> <strong>{str tag=usedonpages section=search.elasticsearch}:</strong>
{else} {else}
<strong>{str tag=usedonpage section=search.elasticsearch}:</strong> <strong>{str tag=usedonpage section=search.elasticsearch}:</strong>
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
{/if} {/if}
</div> </div>
<!-- TAGS --> <!-- TAGS -->
{if $record->tags|count gt 0} {if is_array($record->tags) && count($record->tags) > 0}
<div class="tags"><strong>{str tag=tags section=search.elasticsearch}:</strong> <div class="tags"><strong>{str tag=tags section=search.elasticsearch}:</strong>
{foreach from=$record->tags item=tag name=tags} {foreach from=$record->tags item=tag name=tags}
<a href="{$WWWROOT}search/elasticsearch/index.php?query={$tag}&tagsonly=true">{$tag}</a>{if !$.foreach.tags.last}, {/if} <a href="{$WWWROOT}search/elasticsearch/index.php?query={$tag}&tagsonly=true">{$tag}</a>{if !$.foreach.tags.last}, {/if}
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
{/if} {/if}
</div> </div>
<!-- VIEWS --> <!-- VIEWS -->
{if $record->views|count gt 0} {if is_array($record->views) && count($record->views) > 0}
<div class="col-md-4"> <div class="col-md-4">
<div class="usedon"> <div class="usedon">
{if $record->views} {if $record->views}
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
{/if} {/if}
</div> </div>
<!-- TAGS --> <!-- TAGS -->
{if $record->tags|count gt 0} {if is_array($record->tags) && count($record->tags) > 0}
<div class="tags"> <div class="tags">
<strong>{str tag=tags section=search.elasticsearch}:</strong> <strong>{str tag=tags section=search.elasticsearch}:</strong>
{foreach from=$record->tags item=tag name=tags} {foreach from=$record->tags item=tag name=tags}
...@@ -41,9 +41,9 @@ ...@@ -41,9 +41,9 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<!-- PAGES --> <!-- PAGES -->
{if $record->views|count gt 0} {if is_array($record->views) && count($record->views) > 0}
<div class="usedon"> <div class="usedon">
{if $record->views|count gt 1} {if count($record->views) > 1}
<strong>{str tag=views}:</strong> <strong>{str tag=views}:</strong>
{else} {else}
<strong>{str tag=view}:</strong> <strong>{str tag=view}:</strong>
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
{/if} {/if}
</div> </div>
<!-- TAGS --> <!-- TAGS -->
{if $record->tags|count gt 0} {if is_array($record->tags) && count($record->tags) > 0}
<div class="tags"><strong>{str tag=tags section=search.elasticsearch}:</strong> <div class="tags"><strong>{str tag=tags section=search.elasticsearch}:</strong>
{foreach from=$record->tags item=tag name=tags} {foreach from=$record->tags item=tag name=tags}
<a href="{$WWWROOT}search/elasticsearch/index.php?query={$tag}&tagsonly=true">{$tag}</a>{if !$.foreach.tags.last}, {/if} <a href="{$WWWROOT}search/elasticsearch/index.php?query={$tag}&tagsonly=true">{$tag}</a>{if !$.foreach.tags.last}, {/if}
......
{if count($items) > 0} {if $itemcount}
{foreach from=$items item=view} {foreach from=$items item=view}
<tr class="{cycle values='r0,r1'}"> <tr class="{cycle values='r0,r1'}">
<td class="sv"><a href="{$view->url}">{$view->title}</a>{if $view->collection} <span class="text-small text-midtone">({str tag='nviews' section='view' arg1=$view->viewcount})</span>{/if}</td> <td class="sv"><a href="{$view->url}">{$view->title}</a>{if $view->collection} <span class="text-small text-midtone">({str tag='nviews' section='view' arg1=$view->viewcount})</span>{/if}</td>
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
{$result->description|str_shorten_html:140:true|safe} {$result->description|str_shorten_html:140:true|safe}
</div> </div>
<!-- TAGS --> <!-- TAGS -->
{if $result->tags|count gt 0} {if is_array($result->tags) && count($result->tags) > 0}
<div class="tags"> <div class="tags">
<strong>{str tag=tags}: </strong> <strong>{str tag=tags}: </strong>
{list_tags tags=$result->tags owner=$owner view=$result->viewid} {list_tags tags=$result->tags owner=$owner view=$result->viewid}
...@@ -53,9 +53,9 @@ ...@@ -53,9 +53,9 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<!-- VIEWS --> <!-- VIEWS -->
{if $result->views|count gt 0} {if is_array($result->views) && count($result->views) > 0}
<div class="usedon"> <div class="usedon">
{if $result->views|count gt 1} {if count($result->views) > 1}
<strong>{str tag=usedonpages section=search.elasticsearch}:</strong> <strong>{str tag=usedonpages section=search.elasticsearch}:</strong>
{else} {else}
<strong>{str tag=usedonpage section=search.elasticsearch}:</strong> <strong>{str tag=usedonpage section=search.elasticsearch}:</strong>
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
{$result->description|str_shorten_html:140:true|safe} {$result->description|str_shorten_html:140:true|safe}
</div> </div>
<!-- TAGS --> <!-- TAGS -->
{if $result->tags|count gt 0} {if is_array($result->tags) && count($result->tags) > 0}
<div class="tags"> <div class="tags">
<strong>{str tag=tags}: </strong> <strong>{str tag=tags}: </strong>
{list_tags tags=$result->tags owner=$owner view=$result->viewid} {list_tags tags=$result->tags owner=$owner view=$result->viewid}
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<!-- VIEWS --> <!-- VIEWS -->
{if $result->views|count gt 0} {if is_array($result->views) && count($result->views) > 0}
<div class="usedon"> <div class="usedon">
<strong>{str tag=usedonpage section=search.elasticsearch}:</strong> <strong>{str tag=usedonpage section=search.elasticsearch}:</strong>
<ul class="list-group list-unstyled"> <ul class="list-group list-unstyled">
...@@ -146,16 +146,16 @@ ...@@ -146,16 +146,16 @@
<p> <p>
{$result->description|str_shorten_html:100|strip_tags|safe} {$result->description|str_shorten_html:100|strip_tags|safe}
</p> </p>
{if $result->tags|count gt 0} {if is_array($result->tags) && count($result->tags) > 0}
<div class="tags"><strong>{str tag=tags}:</strong> <div class="tags"><strong>{str tag=tags}:</strong>
{list_tags tags=$result->tags owner=$owner view=$result->viewid} {list_tags tags=$result->tags owner=$owner view=$result->viewid}
</div> </div>
{/if} {/if}
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
{if $result->views|count gt 0} {if is_array($result->views) && count($result->views) > 0}
<div class="usedon"> <div class="usedon">
{if $result->views|count gt 1} {if count($result->views) > 1}
<strong>{str tag=views}:</strong> <strong>{str tag=views}:</strong>
{else} {else}
<strong>{str tag=view}:</strong> <strong>{str tag=view}:</strong>
......
Markdown is supported
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