From 36bd93f1384ccf3f3ccd6fa884ad594d1b486367 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 7 Aug 2015 17:27:08 +0200 Subject: [PATCH] PHP7: Fixed some E_WARNING errors that previously were E_STRICT --- bin/deluser.sh | 2 +- index.php | 2 +- .../example_addressbook_backend.php | 4 ++-- .../lib/Roundcube/rcube_sieve_vacation.php | 4 +++- program/include/rcmail.php | 10 ++++---- program/lib/Roundcube/bootstrap.php | 3 ++- program/lib/Roundcube/rcube.php | 4 ++-- .../lib/Roundcube/rcube_content_filter.php | 2 +- program/lib/Roundcube/rcube_ldap.php | 9 +++++--- program/lib/Roundcube/rcube_ldap_generic.php | 8 ++++--- tests/Framework/DBOracle.php | 22 ++++++++++++++++++ tests/Framework/ImapSearch.php | 20 ++++++++++++++++ tests/Framework/Ldap.php | 23 +++++++++++++++++++ tests/Framework/ResultMultifolder.php | 20 ++++++++++++++++ tests/Selenium/bootstrap.php | 2 +- tests/bootstrap.php | 2 +- tests/phpunit.xml | 4 ++++ 17 files changed, 120 insertions(+), 21 deletions(-) create mode 100644 tests/Framework/DBOracle.php create mode 100644 tests/Framework/ImapSearch.php create mode 100644 tests/Framework/Ldap.php create mode 100644 tests/Framework/ResultMultifolder.php diff --git a/bin/deluser.sh b/bin/deluser.sh index 1e93793cf..06505ef53 100755 --- a/bin/deluser.sh +++ b/bin/deluser.sh @@ -37,7 +37,7 @@ function _die($msg, $usage=false) exit(1); } -$rcmail = rcmail::get_instance(); +$rcmail = rcube::get_instance(); // get arguments $args = rcube_utils::get_opt(array('h' => 'host')); diff --git a/index.php b/index.php index c029b5a26..1ebbdca25 100644 --- a/index.php +++ b/index.php @@ -40,7 +40,7 @@ require_once 'program/include/iniset.php'; // init application, start session, init output class, etc. -$RCMAIL = rcmail::get_instance($GLOBALS['env']); +$RCMAIL = rcmail::get_instance(0, $GLOBALS['env']); // Make the whole PHP output non-cacheable (#1487797) $RCMAIL->output->nocacheing_headers(); diff --git a/plugins/example_addressbook/example_addressbook_backend.php b/plugins/example_addressbook/example_addressbook_backend.php index 8c143c25f..c965d5a28 100644 --- a/plugins/example_addressbook/example_addressbook_backend.php +++ b/plugins/example_addressbook/example_addressbook_backend.php @@ -44,7 +44,7 @@ class example_addressbook_backend extends rcube_addressbook $this->filter = null; } - function list_groups($search = null) + function list_groups($search = null, $mode = 0) { return array( array('ID' => 'testgroup1', 'name' => "Testgroup"), @@ -98,7 +98,7 @@ class example_addressbook_backend extends rcube_addressbook return false; } - function rename_group($gid, $newname) + function rename_group($gid, $newname, &$newid) { return $newname; } diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php index 2779d2f1b..2c26de195 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php @@ -49,9 +49,11 @@ class rcube_sieve_vacation extends rcube_sieve_engine /** * Find and load sieve script with/for vacation rule * + * @param string $script_name Optional script name + * * @return int Connection status: 0 on success, >0 on failure */ - protected function load_script() + protected function load_script($script_name = null) { if ($this->script_name !== null) { return 0; diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 6a40bec56..10a9d64f8 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -65,11 +65,12 @@ class rcmail extends rcube /** * This implements the 'singleton' design pattern * - * @param string Environment name to run (e.g. live, dev, test) + * @param integer $mode Ignored rcube::get_instance() argument + * @param string $env Environment name to run (e.g. live, dev, test) * * @return rcmail The one and only instance */ - static function get_instance($env = '') + static function get_instance($mode = 0, $env = '') { if (!self::$instance || !is_a(self::$instance, 'rcmail')) { self::$instance = new rcmail($env); @@ -94,8 +95,9 @@ class rcmail extends rcube } // load all configured plugins - $this->plugins->load_plugins((array)$this->config->get('plugins', array()), - array('filesystem_attachments', 'jqueryui')); + $plugins = (array) $this->config->get('plugins', array()); + $required_plugins = array('filesystem_attachments', 'jqueryui'); + $this->plugins->load_plugins($plugins, $required_plugins); // start session $this->session_init(); diff --git a/program/lib/Roundcube/bootstrap.php b/program/lib/Roundcube/bootstrap.php index 2e5d9e678..7acd4a4d3 100644 --- a/program/lib/Roundcube/bootstrap.php +++ b/program/lib/Roundcube/bootstrap.php @@ -25,7 +25,8 @@ */ $config = array( - 'error_reporting' => E_ALL & ~E_NOTICE & ~E_STRICT, +// 'error_reporting' => E_ALL & ~E_NOTICE & ~E_STRICT, + 'error_reporting' => E_STRICT, // Some users are not using Installer, so we'll check some // critical PHP settings here. Only these, which doesn't provide // an error/warning in the logs later. See (#1486307). diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php index 7452287c3..d452ea800 100644 --- a/program/lib/Roundcube/rcube.php +++ b/program/lib/Roundcube/rcube.php @@ -124,8 +124,8 @@ class rcube /** * This implements the 'singleton' design pattern * - * @param integer Options to initialize with this instance. See rcube::INIT_WITH_* constants - * @param string Environment name to run (e.g. live, dev, test) + * @param integer $mode Options to initialize with this instance. See rcube::INIT_WITH_* constants + * @param string $env Environment name to run (e.g. live, dev, test) * * @return rcube The one and only instance */ diff --git a/program/lib/Roundcube/rcube_content_filter.php b/program/lib/Roundcube/rcube_content_filter.php index e0de98b7d..88f780666 100644 --- a/program/lib/Roundcube/rcube_content_filter.php +++ b/program/lib/Roundcube/rcube_content_filter.php @@ -33,7 +33,7 @@ class rcube_content_filter extends php_user_filter return true; } - function filter($in, $out, &$consumed) + function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $this->buffer .= $bucket->data; diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php index e8f9a8e72..f1ebea09a 100644 --- a/program/lib/Roundcube/rcube_ldap.php +++ b/program/lib/Roundcube/rcube_ldap.php @@ -1051,11 +1051,14 @@ class rcube_ldap extends rcube_addressbook /** * Create a new contact record * - * @param array Hash array with save data + * @param array Associative array with save data + * Keys: Field name with optional section in the form FIELD:SECTION + * Values: Field value. Can be either a string or an array of strings for multiple values + * @param boolean True to check for duplicates first * - * @return encoded record ID on success, False on error + * @return mixed The created record ID on success, False on error */ - function insert($save_cols) + function insert($save_cols, $check = false) { // Map out the column names to their LDAP ones to build the new entry. $newentry = $this->_map_data($save_cols); diff --git a/program/lib/Roundcube/rcube_ldap_generic.php b/program/lib/Roundcube/rcube_ldap_generic.php index 74ac7f7e1..d0b3576a7 100644 --- a/program/lib/Roundcube/rcube_ldap_generic.php +++ b/program/lib/Roundcube/rcube_ldap_generic.php @@ -57,12 +57,13 @@ class rcube_ldap_generic extends Net_LDAP3 * Get a specific LDAP entry, identified by its DN * * @param string $dn Record identifier + * @param array $attributes Attributes to return * * @return array Hash array */ - function get_entry($dn) + function get_entry($dn, $attributes = array()) { - return parent::get_entry($dn, $this->attributes); + return parent::get_entry($dn, !empty($attributes) ? $attributes : $this->attributes); } /** @@ -284,10 +285,11 @@ class rcube_ldap_generic extends Net_LDAP3 * Turn an LDAP entry into a regular PHP array with attributes as keys. * * @param array $entry Attributes array as retrieved from ldap_get_attributes() or ldap_get_entries() + * @param bool $flat Convert one-element-array values into strings (not implemented) * * @return array Hash array with attributes as keys */ - public static function normalize_entry($entry) + public static function normalize_entry($entry, $flat = false) { if (!isset($entry['count'])) { return $entry; diff --git a/tests/Framework/DBOracle.php b/tests/Framework/DBOracle.php new file mode 100644 index 000000000..27e138d1f --- /dev/null +++ b/tests/Framework/DBOracle.php @@ -0,0 +1,22 @@ +assertInstanceOf('rcube_db_oracle', $object, "Class constructor"); + } +} diff --git a/tests/Framework/ImapSearch.php b/tests/Framework/ImapSearch.php new file mode 100644 index 000000000..f91139c00 --- /dev/null +++ b/tests/Framework/ImapSearch.php @@ -0,0 +1,20 @@ +assertInstanceOf('rcube_imap_search', $object, "Class constructor"); + } +} diff --git a/tests/Framework/Ldap.php b/tests/Framework/Ldap.php new file mode 100644 index 000000000..8306907e4 --- /dev/null +++ b/tests/Framework/Ldap.php @@ -0,0 +1,23 @@ +markTestSkipped('We do not connect to LDAP'); + + $object = new rcube_ldap(array()); + + $this->assertInstanceOf('rcube_ldap', $object, "Class constructor"); + } +} diff --git a/tests/Framework/ResultMultifolder.php b/tests/Framework/ResultMultifolder.php new file mode 100644 index 000000000..83a2b1d96 --- /dev/null +++ b/tests/Framework/ResultMultifolder.php @@ -0,0 +1,20 @@ +assertInstanceOf('rcube_result_multifolder', $object, "Class constructor"); + } +} diff --git a/tests/Selenium/bootstrap.php b/tests/Selenium/bootstrap.php index dc4897de1..9baf0c09c 100644 --- a/tests/Selenium/bootstrap.php +++ b/tests/Selenium/bootstrap.php @@ -38,7 +38,7 @@ if (set_include_path($include_path) === false) { die("Fatal error: ini_set/set_include_path does not work."); } -$rcmail = rcmail::get_instance('test'); +$rcmail = rcmail::get_instance(0, 'test'); define('TESTS_URL', $rcmail->config->get('tests_url')); define('TESTS_BROWSER', $rcmail->config->get('tests_browser', 'firefox')); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index bf7199c1e..925cca66a 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -32,7 +32,7 @@ if (@is_dir(TESTS_DIR . 'config')) { require_once(INSTALL_PATH . 'program/include/iniset.php'); -rcmail::get_instance('test')->config->set('devel_mode', false); +rcmail::get_instance(0, 'test')->config->set('devel_mode', false); // Extend include path so some plugin test won't fail $include_path = ini_get('include_path') . PATH_SEPARATOR . TESTS_DIR . '..'; diff --git a/tests/phpunit.xml b/tests/phpunit.xml index f5cac92f6..07d8d4181 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -15,6 +15,7 @@ Framework/DB.php Framework/DBMssql.php Framework/DBMysql.php + Framework/DBOracle.php Framework/DBPgsql.php Framework/DBSqlite.php Framework/DBSqlsrv.php @@ -24,13 +25,16 @@ Framework/Imap.php Framework/ImapCache.php Framework/ImapGeneric.php + Framework/ImapSearch.php Framework/Image.php + Framework/Ldap.php Framework/LdapGeneric.php Framework/MessageHeader.php Framework/MessagePart.php Framework/Mime.php Framework/Rcube.php Framework/ResultIndex.php + Framework/ResultMultifolder.php Framework/ResultSet.php Framework/ResultThread.php Framework/Smtp.php