From f1437d4ccb9dbdd6614b1f54c6bf18fd59caefdf Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 13 Apr 2018 09:11:03 +0200 Subject: [PATCH] fixing a couple more PHP Warning count(): Parameter must be an array or an object that implements Countable --- .../inc/class.addressbook_groupdav.inc.php | 2 +- api/src/Db.php | 2 +- api/src/Hooks.php | 3 +- api/src/Link.php | 4 +- mail/inc/class.mail_ui.inc.php | 43 +++++++++---------- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index a0b0f5216d..6c2148178e 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -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 - 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]"); // add accounts after contacts, if enabled and stored in different repository diff --git a/api/src/Db.php b/api/src/Db.php index 9c0c6caf6e..48e542d6e8 100644 --- a/api/src/Db.php +++ b/api/src/Db.php @@ -1939,7 +1939,7 @@ class Db { $table = self::$tablealiases[$table]; } - if (count($data)) + if (!empty($data)) { $inputarr = false; if ($use_prepared_statement && $this->Link_ID->_bindInputArray) // eg. MaxDB diff --git a/api/src/Hooks.php b/api/src/Hooks.php index 83085c6ed2..67f825f1bb 100644 --- a/api/src/Hooks.php +++ b/api/src/Hooks.php @@ -194,7 +194,8 @@ class Hooks if (!isset(self::$locations)) self::read(); //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])); } /** diff --git a/api/src/Link.php b/api/src/Link.php index 5eba4b6f62..c191762b7e 100644 --- a/api/src/Link.php +++ b/api/src/Link.php @@ -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)); - 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); } 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); } diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index f74fb31b36..e0f3c50ad8 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -1935,46 +1935,45 @@ $filter['before']= date("d-M-Y", $cutoffdate2); //error_log(__METHOD__.__LINE__.array2string($header)); if (in_array("attachments", $cols)) { - if($header['mimetype'] == 'multipart/mixed' || - $header['mimetype'] == 'multipart/signed' || - $header['mimetype'] == 'multipart/related' || - $header['mimetype'] == 'multipart/report' || - $header['mimetype'] == 'text/calendar' || - $header['mimetype'] == 'text/html' || + if (!empty($header['attachments']) && (in_array($header['mimetype'], array( + 'multipart/mixed', 'multipart/signed', 'multipart/related', 'multipart/report', + 'text/calendar', 'text/html', 'multipart/alternative', + )) || substr($header['mimetype'],0,11) == 'application' || substr($header['mimetype'],0,5) == 'audio' || - substr($header['mimetype'],0,5) == 'video' || - $header['mimetype'] == 'multipart/alternative') + substr($header['mimetype'],0,5) == 'video')) { $image = Api\Html::image('mail','attach'); - $imageHTMLBlock = ''; $datarowid = $this->createRowID($_folderName,$message_uid,true); $attachments = $header['attachments']; - if (count($attachments)<1) + if (count($attachments) == 1) { - $image = ' '; - } - 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'].')':'')); } - if (count($attachments)>1) + else { - $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName); $image = Api\Html::image('mail','attach',lang('%1 attachments',count($attachments))); } + $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName); $attachmentFlag = $image; - } else { - $attachmentFlag =' '; + } + else + { + $attachmentFlag = ' '; + $imageHTMLBlock = ''; } // show priority flag - if ($header['priority'] < 3) { + if ($header['priority'] < 3) + { $image = Api\Html::image('mail','prio_high'); - } elseif ($header['priority'] > 3) { + } + elseif ($header['priority'] > 3) + { $image = Api\Html::image('mail','prio_low'); - } else { + } + else + { $image = ''; } // show a flag for flagged messages