From 1b39d9a6c744a393e7930c2493cc2ddc9c9e95bf Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 08 Aug 2015 03:32:24 -0400
Subject: [PATCH] PHP7: Fixed some E_WARNING errors that previously were E_STRICT
---
program/lib/Roundcube/rcube.php | 4
tests/Selenium/bootstrap.php | 2
tests/Framework/ResultMultifolder.php | 20 ++++++
tests/Framework/DBOracle.php | 22 +++++++
tests/Framework/Ldap.php | 23 +++++++
bin/deluser.sh | 2
plugins/example_addressbook/example_addressbook_backend.php | 4
tests/bootstrap.php | 2
plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php | 4 +
index.php | 2
program/lib/Roundcube/rcube_ldap_generic.php | 8 +-
program/include/rcmail.php | 10 ++-
program/lib/Roundcube/rcube_ldap.php | 9 ++-
tests/Framework/ImapSearch.php | 20 ++++++
tests/phpunit.xml | 4 +
program/lib/Roundcube/rcube_content_filter.php | 2
16 files changed, 118 insertions(+), 20 deletions(-)
diff --git a/bin/deluser.sh b/bin/deluser.sh
index 1e93793..06505ef 100755
--- a/bin/deluser.sh
+++ b/bin/deluser.sh
@@ -37,7 +37,7 @@
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 c029b5a..1ebbdca 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 8c143c2..c965d5a 100644
--- a/plugins/example_addressbook/example_addressbook_backend.php
+++ b/plugins/example_addressbook/example_addressbook_backend.php
@@ -44,7 +44,7 @@
$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 @@
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 2779d2f..2c26de1 100644
--- a/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php
+++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php
@@ -49,9 +49,11 @@
/**
* 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 6a40bec..10a9d64 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -65,11 +65,12 @@
/**
* 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 @@
}
// 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/rcube.php b/program/lib/Roundcube/rcube.php
index 7452287..d452ea8 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -124,8 +124,8 @@
/**
* 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 e0de98b..88f7806 100644
--- a/program/lib/Roundcube/rcube_content_filter.php
+++ b/program/lib/Roundcube/rcube_content_filter.php
@@ -33,7 +33,7 @@
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 e8f9a8e..f1ebea0 100644
--- a/program/lib/Roundcube/rcube_ldap.php
+++ b/program/lib/Roundcube/rcube_ldap.php
@@ -1051,11 +1051,14 @@
/**
* 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 74ac7f7..d0b3576 100644
--- a/program/lib/Roundcube/rcube_ldap_generic.php
+++ b/program/lib/Roundcube/rcube_ldap_generic.php
@@ -57,12 +57,13 @@
* 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 @@
* 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 0000000..27e138d
--- /dev/null
+++ b/tests/Framework/DBOracle.php
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Test class to test rcube_db_oracle class
+ *
+ * @package Tests
+ * @group database
+ * @group oracle
+ */
+class Framework_DBOracle extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_db_oracle('test');
+
+ $this->assertInstanceOf('rcube_db_oracle', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/ImapSearch.php b/tests/Framework/ImapSearch.php
new file mode 100644
index 0000000..f91139c
--- /dev/null
+++ b/tests/Framework/ImapSearch.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Test class to test rcube_imap_search class
+ *
+ * @package Tests
+ */
+class Framework_ImapSearch extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_imap_search(array(), true);
+
+ $this->assertInstanceOf('rcube_imap_search', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/Ldap.php b/tests/Framework/Ldap.php
new file mode 100644
index 0000000..8306907
--- /dev/null
+++ b/tests/Framework/Ldap.php
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Test class to test rcube_ldap class
+ *
+ * @package Tests
+ */
+class Framework_Ldap extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ // skip this test as we don't want to connect to ldap here
+ $this->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 0000000..83a2b1d
--- /dev/null
+++ b/tests/Framework/ResultMultifolder.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Test class to test rcube_result_multifolder class
+ *
+ * @package Tests
+ */
+class Framework_ResultMultifolder extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_result_multifolder;
+
+ $this->assertInstanceOf('rcube_result_multifolder', $object, "Class constructor");
+ }
+}
diff --git a/tests/Selenium/bootstrap.php b/tests/Selenium/bootstrap.php
index dc4897d..9baf0c0 100644
--- a/tests/Selenium/bootstrap.php
+++ b/tests/Selenium/bootstrap.php
@@ -38,7 +38,7 @@
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 bf7199c..925cca6 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -32,7 +32,7 @@
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 f5cac92..07d8d41 100644
--- a/tests/phpunit.xml
+++ b/tests/phpunit.xml
@@ -15,6 +15,7 @@
<file>Framework/DB.php</file>
<file>Framework/DBMssql.php</file>
<file>Framework/DBMysql.php</file>
+ <file>Framework/DBOracle.php</file>
<file>Framework/DBPgsql.php</file>
<file>Framework/DBSqlite.php</file>
<file>Framework/DBSqlsrv.php</file>
@@ -24,13 +25,16 @@
<file>Framework/Imap.php</file>
<file>Framework/ImapCache.php</file>
<file>Framework/ImapGeneric.php</file>
+ <file>Framework/ImapSearch.php</file>
<file>Framework/Image.php</file>
+ <file>Framework/Ldap.php</file>
<file>Framework/LdapGeneric.php</file>
<file>Framework/MessageHeader.php</file>
<file>Framework/MessagePart.php</file>
<file>Framework/Mime.php</file>
<file>Framework/Rcube.php</file>
<file>Framework/ResultIndex.php</file>
+ <file>Framework/ResultMultifolder.php</file>
<file>Framework/ResultSet.php</file>
<file>Framework/ResultThread.php</file>
<file>Framework/Smtp.php</file>
--
Gitblit v1.9.1