johndoh/roundcube-sauserprefs

count() error in sauserprefs.php

Closed this issue · 3 comments

The following line of sauserprefs.php (#110 in v1.17.1):
elseif (count($this->addressbook_sync) > 0) {

needs to be changed to:
elseif (is_array($this->addressbook_sync) && count($this->addressbook_sync) > 0) {

to prevent errors like this when using PHP7:

PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/roundcubemail-1.3.7/plugins/sauserprefs/sauserprefs.php on line 110

please check if this change from the master branch solves the issue:

--- a/sauserprefs.php
+++ b/sauserprefs.php
@@ -36,8 +36,8 @@ class sauserprefs extends rcube_plugin
     private $global_prefs;
     private $user_prefs;
     private $score_prefs = array();
-    private $addressbook_import;
-    private $addressbook_sync;
+    private $addressbook_import = array();
+    private $addressbook_sync = array();
     private $sa_locales = array('en', 'ja', 'ko', 'ru', 'th', 'zh');
     private $sa_user;
     private $bayes_query;

this should be fixed in release-1.17 branch now. please confirm

It seems to work for me. Thanks for that.