fixing a couple more PHP Warning count(): Parameter must be an array or an object that implements Countable

This commit is contained in:
Ralf Becker 2018-04-13 09:11:03 +02:00
parent 5f160114e9
commit f1437d4ccb
5 changed files with 27 additions and 27 deletions

View File

@ -263,7 +263,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler
} }
} }
// last chunk or no chunking: add accounts from different repo and report missing multiget urls // last chunk or no chunking: add accounts from different repo and report missing multiget urls
if (!$start || count($contacts) < $start[1]) if (!$start || (empty($contact)?0:count($contacts)) < $start[1])
{ {
//error_log(__METHOD__."('$path', ".array2string($filter).", ".array2string($start)."; $report_not_found_multiget_ids) last chunk detected: count()=".count($contacts)." < $start[1]"); //error_log(__METHOD__."('$path', ".array2string($filter).", ".array2string($start)."; $report_not_found_multiget_ids) last chunk detected: count()=".count($contacts)." < $start[1]");
// add accounts after contacts, if enabled and stored in different repository // add accounts after contacts, if enabled and stored in different repository

View File

@ -1939,7 +1939,7 @@ class Db
{ {
$table = self::$tablealiases[$table]; $table = self::$tablealiases[$table];
} }
if (count($data)) if (!empty($data))
{ {
$inputarr = false; $inputarr = false;
if ($use_prepared_statement && $this->Link_ID->_bindInputArray) // eg. MaxDB if ($use_prepared_statement && $this->Link_ID->_bindInputArray) // eg. MaxDB

View File

@ -194,7 +194,8 @@ class Hooks
if (!isset(self::$locations)) self::read(); if (!isset(self::$locations)) self::read();
//error_log(__METHOD__.__LINE__.array2string(self::$locations[$location])); //error_log(__METHOD__.__LINE__.array2string(self::$locations[$location]));
return $return_methods ? self::$locations[$location][$app] : count(self::$locations[$location][$app]); return $return_methods ? self::$locations[$location][$app] :
(empty(self::$locations[$location][$app]) ? 0 : count(self::$locations[$location][$app]));
} }
/** /**

View File

@ -313,13 +313,13 @@ class Link extends Link\Storage
{ {
//error_log(__METHOD__.'() items in title-cache: '.count(self::$title_cache).' file-access-cache: '.count(self::$file_access_cache)); //error_log(__METHOD__.'() items in title-cache: '.count(self::$title_cache).' file-access-cache: '.count(self::$file_access_cache));
if (count(self::$title_cache > self::TITLE_CACHE_SIZE)) if (count(self::$title_cache) > self::TITLE_CACHE_SIZE)
{ {
self::$title_cache = array_slice(self::$title_cache, -self::TITLE_CACHE_SIZE); self::$title_cache = array_slice(self::$title_cache, -self::TITLE_CACHE_SIZE);
} }
Cache::setSession(__CLASS__, 'link_title_cache', self::$title_cache); Cache::setSession(__CLASS__, 'link_title_cache', self::$title_cache);
if (count(self::$file_access_cache > self::FILE_ACCESS_CACHE_SIZE)) if (count(self::$file_access_cache) > self::FILE_ACCESS_CACHE_SIZE)
{ {
self::$file_access_cache = array_slice(self::$file_access_cache, -self::FILE_ACCESS_CACHE_SIZE); self::$file_access_cache = array_slice(self::$file_access_cache, -self::FILE_ACCESS_CACHE_SIZE);
} }

View File

@ -1935,46 +1935,45 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
//error_log(__METHOD__.__LINE__.array2string($header)); //error_log(__METHOD__.__LINE__.array2string($header));
if (in_array("attachments", $cols)) if (in_array("attachments", $cols))
{ {
if($header['mimetype'] == 'multipart/mixed' || if (!empty($header['attachments']) && (in_array($header['mimetype'], array(
$header['mimetype'] == 'multipart/signed' || 'multipart/mixed', 'multipart/signed', 'multipart/related', 'multipart/report',
$header['mimetype'] == 'multipart/related' || 'text/calendar', 'text/html', 'multipart/alternative',
$header['mimetype'] == 'multipart/report' || )) ||
$header['mimetype'] == 'text/calendar' ||
$header['mimetype'] == 'text/html' ||
substr($header['mimetype'],0,11) == 'application' || substr($header['mimetype'],0,11) == 'application' ||
substr($header['mimetype'],0,5) == 'audio' || substr($header['mimetype'],0,5) == 'audio' ||
substr($header['mimetype'],0,5) == 'video' || substr($header['mimetype'],0,5) == 'video'))
$header['mimetype'] == 'multipart/alternative')
{ {
$image = Api\Html::image('mail','attach'); $image = Api\Html::image('mail','attach');
$imageHTMLBlock = '';
$datarowid = $this->createRowID($_folderName,$message_uid,true); $datarowid = $this->createRowID($_folderName,$message_uid,true);
$attachments = $header['attachments']; $attachments = $header['attachments'];
if (count($attachments)<1) if (count($attachments) == 1)
{ {
$image = '&nbsp;';
}
if (count($attachments)==1)
{
$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
$image = Api\Html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':'')); $image = Api\Html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':''));
} }
if (count($attachments)>1) else
{ {
$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
$image = Api\Html::image('mail','attach',lang('%1 attachments',count($attachments))); $image = Api\Html::image('mail','attach',lang('%1 attachments',count($attachments)));
} }
$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
$attachmentFlag = $image; $attachmentFlag = $image;
} else { }
$attachmentFlag ='&nbsp;'; else
{
$attachmentFlag = '&nbsp;';
$imageHTMLBlock = '';
} }
// show priority flag // show priority flag
if ($header['priority'] < 3) { if ($header['priority'] < 3)
{
$image = Api\Html::image('mail','prio_high'); $image = Api\Html::image('mail','prio_high');
} elseif ($header['priority'] > 3) { }
elseif ($header['priority'] > 3)
{
$image = Api\Html::image('mail','prio_low'); $image = Api\Html::image('mail','prio_low');
} else { }
else
{
$image = ''; $image = '';
} }
// show a flag for flagged messages // show a flag for flagged messages