summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-08-10 14:26:57 +0200
committerAndrey Andreev <narf@devilix.net>2016-08-10 14:26:57 +0200
commitc4bd43432df03e4f4835c7689c8ed722cd2c3020 (patch)
tree5603166833d78b0581bbe880adb53b6de085719d
parent488ad40ba334ca506f07bede97724726eac2b27f (diff)
parent9180a1264dc536c34e5cc8a0e44bb399a8ba484f (diff)
Merge branch '3.1-stable' into develop
-rw-r--r--system/core/CodeIgniter.php6
-rw-r--r--system/core/Security.php7
-rw-r--r--system/core/compat/password.php2
-rw-r--r--system/core/compat/standard.php207
-rw-r--r--system/database/DB_query_builder.php4
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php7
-rw-r--r--system/database/drivers/oci8/oci8_driver.php2
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php16
-rw-r--r--system/helpers/date_helper.php79
-rw-r--r--system/libraries/Email.php12
-rw-r--r--system/libraries/Encryption.php6
-rw-r--r--system/libraries/Form_validation.php13
-rw-r--r--system/libraries/Image_lib.php2
-rw-r--r--system/libraries/Migration.php5
-rw-r--r--system/libraries/Session/drivers/Session_files_driver.php15
-rw-r--r--system/libraries/Session/drivers/Session_memcached_driver.php8
-rw-r--r--system/libraries/Upload.php41
-rw-r--r--tests/Bootstrap.php6
-rw-r--r--tests/codeigniter/core/Loader_test.php4
-rw-r--r--tests/codeigniter/core/Log_test.php10
-rw-r--r--tests/codeigniter/core/compat/password_test.php5
-rw-r--r--tests/codeigniter/core/compat/standard_test.php202
-rw-r--r--tests/codeigniter/helpers/date_helper_test.php4
-rw-r--r--tests/codeigniter/helpers/language_helper_test.php4
-rw-r--r--tests/codeigniter/helpers/number_helper_test.php4
-rw-r--r--tests/codeigniter/libraries/Calendar_test.php6
-rw-r--r--tests/codeigniter/libraries/Driver_test.php4
-rw-r--r--tests/codeigniter/libraries/Form_validation_test.php7
-rw-r--r--tests/codeigniter/libraries/Upload_test.php16
-rw-r--r--user_guide_src/source/changelog.rst8
-rw-r--r--user_guide_src/source/general/compatibility_functions.rst32
-rw-r--r--user_guide_src/source/general/hooks.rst4
-rw-r--r--user_guide_src/source/general/routing.rst4
-rw-r--r--user_guide_src/source/general/security.rst7
-rw-r--r--user_guide_src/source/libraries/encryption.rst2
-rw-r--r--user_guide_src/source/libraries/form_validation.rst5
36 files changed, 88 insertions, 678 deletions
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 5e60a8d40..e6ce13d81 100644
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -416,11 +416,7 @@ if ( ! is_php('5.4'))
$params = array($method, array_slice($URI->rsegments, 2));
$method = '_remap';
}
- // WARNING: It appears that there are issues with is_callable() even in PHP 5.2!
- // Furthermore, there are bug reports and feature/change requests related to it
- // that make it unreliable to use in this context. Please, DO NOT change this
- // work-around until a better alternative is available.
- elseif ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($class)), TRUE))
+ elseif ( ! is_callable(array($class, $method)))
{
$e404 = TRUE;
}
diff --git a/system/core/Security.php b/system/core/Security.php
index d5305d1ca..a29070095 100644
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -678,12 +678,7 @@ class CI_Security {
{
if ( ! isset($_entities))
{
- $_entities = array_map(
- 'strtolower',
- is_php('5.3.4')
- ? get_html_translation_table(HTML_ENTITIES, $flag, $charset)
- : get_html_translation_table(HTML_ENTITIES, $flag)
- );
+ $_entities = array_map('strtolower', get_html_translation_table(HTML_ENTITIES, $flag, $charset));
// If we're not on PHP 5.4+, add the possibly dangerous HTML 5
// entities to the array manually
diff --git a/system/core/compat/password.php b/system/core/compat/password.php
index 76dd2cf0a..1b5219e7b 100644
--- a/system/core/compat/password.php
+++ b/system/core/compat/password.php
@@ -50,7 +50,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
// ------------------------------------------------------------------------
-if (is_php('5.5') OR ! is_php('5.3.7') OR ! defined('CRYPT_BLOWFISH') OR CRYPT_BLOWFISH !== 1 OR defined('HHVM_VERSION'))
+if (is_php('5.5') OR ! defined('CRYPT_BLOWFISH') OR CRYPT_BLOWFISH !== 1 OR defined('HHVM_VERSION'))
{
return;
}
diff --git a/system/core/compat/standard.php b/system/core/compat/standard.php
index c54cab951..c839c9bc9 100644
--- a/system/core/compat/standard.php
+++ b/system/core/compat/standard.php
@@ -180,210 +180,3 @@ if ( ! function_exists('hex2bin'))
return pack('H*', $data);
}
}
-
-// ------------------------------------------------------------------------
-
-if (is_php('5.3'))
-{
- return;
-}
-
-// ------------------------------------------------------------------------
-
-if ( ! function_exists('array_replace'))
-{
- /**
- * array_replace()
- *
- * @link http://php.net/array_replace
- * @return array
- */
- function array_replace()
- {
- $arrays = func_get_args();
-
- if (($c = count($arrays)) === 0)
- {
- trigger_error('array_replace() expects at least 1 parameter, 0 given', E_USER_WARNING);
- return NULL;
- }
- elseif ($c === 1)
- {
- if ( ! is_array($arrays[0]))
- {
- trigger_error('array_replace(): Argument #1 is not an array', E_USER_WARNING);
- return NULL;
- }
-
- return $arrays[0];
- }
-
- $array = array_shift($arrays);
- $c--;
-
- for ($i = 0; $i < $c; $i++)
- {
- if ( ! is_array($arrays[$i]))
- {
- trigger_error('array_replace(): Argument #'.($i + 2).' is not an array', E_USER_WARNING);
- return NULL;
- }
- elseif (empty($arrays[$i]))
- {
- continue;
- }
-
- foreach (array_keys($arrays[$i]) as $key)
- {
- $array[$key] = $arrays[$i][$key];
- }
- }
-
- return $array;
- }
-}
-
-// ------------------------------------------------------------------------
-
-if ( ! function_exists('array_replace_recursive'))
-{
- /**
- * array_replace_recursive()
- *
- * @link http://php.net/array_replace_recursive
- * @return array
- */
- function array_replace_recursive()
- {
- $arrays = func_get_args();
-
- if (($c = count($arrays)) === 0)
- {
- trigger_error('array_replace_recursive() expects at least 1 parameter, 0 given', E_USER_WARNING);
- return NULL;
- }
- elseif ($c === 1)
- {
- if ( ! is_array($arrays[0]))
- {
- trigger_error('array_replace_recursive(): Argument #1 is not an array', E_USER_WARNING);
- return NULL;
- }
-
- return $arrays[0];
- }
-
- $array = array_shift($arrays);
- $c--;
-
- for ($i = 0; $i < $c; $i++)
- {
- if ( ! is_array($arrays[$i]))
- {
- trigger_error('array_replace_recursive(): Argument #'.($i + 2).' is not an array', E_USER_WARNING);
- return NULL;
- }
- elseif (empty($arrays[$i]))
- {
- continue;
- }
-
- foreach (array_keys($arrays[$i]) as $key)
- {
- $array[$key] = (is_array($arrays[$i][$key]) && isset($array[$key]) && is_array($array[$key]))
- ? array_replace_recursive($array[$key], $arrays[$i][$key])
- : $arrays[$i][$key];
- }
- }
-
- return $array;
- }
-}
-
-// ------------------------------------------------------------------------
-
-if ( ! function_exists('quoted_printable_encode'))
-{
- /**
- * quoted_printable_encode()
- *
- * @link http://php.net/quoted_printable_encode
- * @param string $str
- * @return string
- */
- function quoted_printable_encode($str)
- {
- if (strlen($str) === 0)
- {
- return '';
- }
- elseif (in_array($type = gettype($str), array('array', 'object'), TRUE))
- {
- if ($type === 'object' && method_exists($str, '__toString'))
- {
- $str = (string) $str;
- }
- else
- {
- trigger_error('quoted_printable_encode() expects parameter 1 to be string, '.$type.' given', E_USER_WARNING);
- return NULL;
- }
- }
-
- if (function_exists('imap_8bit'))
- {
- return imap_8bit($str);
- }
-
- $i = $lp = 0;
- $output = '';
- $hex = '0123456789ABCDEF';
- $length = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'))
- ? mb_strlen($str, '8bit')
- : strlen($str);
-
- while ($length--)
- {
- if ((($c = $str[$i++]) === "\015") && isset($str[$i]) && ($str[$i] === "\012") && $length > 0)
- {
- $output .= "\015".$str[$i++];
- $length--;
- $lp = 0;
- continue;
- }
-
- if (
- ctype_cntrl($c)
- OR (ord($c) === 0x7f)
- OR (ord($c) & 0x80)
- OR ($c === '=')
- OR ($c === ' ' && isset($str[$i]) && $str[$i] === "\015")
- )
- {
- if (
- (($lp += 3) > 75 && ord($c) <= 0x7f)
- OR (ord($c) > 0x7f && ord($c) <= 0xdf && ($lp + 3) > 75)
- OR (ord($c) > 0xdf && ord($c) <= 0xef && ($lp + 6) > 75)
- OR (ord($c) > 0xef && ord($c) <= 0xf4 && ($lp + 9) > 75)
- )
- {
- $output .= "=\015\012";
- $lp = 3;
- }
-
- $output .= '='.$hex[ord($c) >> 4].$hex[ord($c) & 0xf];
- continue;
- }
-
- if ((++$lp) > 75)
- {
- $output .= "=\015\012";
- $lp = 1;
- }
-
- $output .= $c;
- }
-
- return $output;
- }
-}
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 713bf18f3..7a008eeb8 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -1271,7 +1271,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
*/
protected function _limit($sql)
{
- return $sql.' LIMIT '.($this->qb_offset ? $this->qb_offset.', ' : '').$this->qb_limit;
+ return $sql.' LIMIT '.($this->qb_offset ? $this->qb_offset.', ' : '').(int) $this->qb_limit;
}
// --------------------------------------------------------------------
@@ -2340,7 +2340,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
.$this->_compile_order_by(); // ORDER BY
// LIMIT
- if ($this->qb_limit)
+ if ($this->qb_limit OR $this->qb_offset)
{
return $this->_limit($sql."\n");
}
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 168533240..c26f975c4 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -125,8 +125,7 @@ class CI_DB_mysqli_driver extends CI_DB {
}
else
{
- // Persistent connection support was added in PHP 5.3.0
- $hostname = ($persistent === TRUE && is_php('5.3'))
+ $hostname = ($persistent === TRUE)
? 'p:'.$this->hostname : $this->hostname;
$port = empty($this->port) ? NULL : $this->port;
$socket = NULL;
@@ -496,8 +495,8 @@ class CI_DB_mysqli_driver extends CI_DB {
if ( ! empty($this->_mysqli->connect_errno))
{
return array(
- 'code' => $this->_mysqli->connect_errno,
- 'message' => is_php('5.2.9') ? $this->_mysqli->connect_error : mysqli_connect_error()
+ 'code' => $this->_mysqli->connect_errno,
+ 'message' => $this->_mysqli->connect_error
);
}
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index df7e0848a..56fdf32cf 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -386,7 +386,7 @@ class CI_DB_oci8_driver extends CI_DB {
*/
protected function _trans_begin()
{
- $this->commit_mode = is_php('5.3.2') ? OCI_NO_AUTO_COMMIT : OCI_DEFAULT;
+ $this->commit_mode = OCI_NO_AUTO_COMMIT;
return TRUE;
}
diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
index 38a5a8aff..3631cdf7a 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
@@ -106,7 +106,7 @@ class CI_DB_pdo_mysql_driver extends CI_DB_pdo_driver {
empty($this->database) OR $this->dsn .= ';dbname='.$this->database;
empty($this->char_set) OR $this->dsn .= ';charset='.$this->char_set;
}
- elseif ( ! empty($this->char_set) && strpos($this->dsn, 'charset=', 6) === FALSE && is_php('5.3.6'))
+ elseif ( ! empty($this->char_set) && strpos($this->dsn, 'charset=', 6) === FALSE)
{
$this->dsn .= ';charset='.$this->char_set;
}
@@ -122,17 +122,6 @@ class CI_DB_pdo_mysql_driver extends CI_DB_pdo_driver {
*/
public function db_connect($persistent = FALSE)
{
- /* Prior to PHP 5.3.6, even if the charset was supplied in the DSN
- * on connect - it was ignored. This is a work-around for the issue.
- *
- * Reference: http://www.php.net/manual/en/ref.pdo-mysql.connection.php
- */
- if ( ! is_php('5.3.6') && ! empty($this->char_set))
- {
- $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES '.$this->char_set
- .(empty($this->dbcollat) ? '' : ' COLLATE '.$this->dbcollat);
- }
-
if (isset($this->stricton))
{
if ($this->stricton)
@@ -169,8 +158,7 @@ class CI_DB_pdo_mysql_driver extends CI_DB_pdo_driver {
$this->options[PDO::MYSQL_ATTR_COMPRESS] = TRUE;
}
- // SSL support was added to PDO_MYSQL in PHP 5.3.7
- if (is_array($this->encrypt) && is_php('5.3.7'))
+ if (is_array($this->encrypt))
{
$ssl = array();
empty($this->encrypt['ssl_key']) OR $ssl[PDO::MYSQL_ATTR_SSL_KEY] = $this->encrypt['ssl_key'];
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index c43209f05..5f1fcf07e 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -707,87 +707,32 @@ if ( ! function_exists('date_range'))
$range = array();
- /* NOTE: Even though the DateTime object has many useful features, it appears that
- * it doesn't always handle properly timezones, when timestamps are passed
- * directly to its constructor. Neither of the following gave proper results:
- *
- * new DateTime('<timestamp>')
- * new DateTime('<timestamp>', '<timezone>')
- *
- * --- available in PHP 5.3:
- *
- * DateTime::createFromFormat('<format>', '<timestamp>')
- * DateTime::createFromFormat('<format>', '<timestamp>', '<timezone')
- *
- * ... so we'll have to set the timestamp after the object is instantiated.
- * Furthermore, in PHP 5.3 we can use DateTime::setTimestamp() to do that and
- * given that we have UNIX timestamps - we should use it.
- */
$from = new DateTime();
+ $from->setTimestamp($unix_start);
- if (is_php('5.3'))
- {
- $from->setTimestamp($unix_start);
- if ($is_unix)
- {
- $arg = new DateTime();
- $arg->setTimestamp($mixed);
- }
- else
- {
- $arg = (int) $mixed;
- }
-
- $period = new DatePeriod($from, new DateInterval('P1D'), $arg);
- foreach ($period as $date)
- {
- $range[] = $date->format($format);
- }
-
- /* If a period end date was passed to the DatePeriod constructor, it might not
- * be in our results. Not sure if this is a bug or it's just possible because
- * the end date might actually be less than 24 hours away from the previously
- * generated DateTime object, but either way - we have to append it manually.
- */
- if ( ! is_int($arg) && $range[count($range) - 1] !== $arg->format($format))
- {
- $range[] = $arg->format($format);
- }
-
- return $range;
- }
-
- $from->setDate(date('Y', $unix_start), date('n', $unix_start), date('j', $unix_start));
- $from->setTime(date('G', $unix_start), date('i', $unix_start), date('s', $unix_start));
if ($is_unix)
{
$arg = new DateTime();
- $arg->setDate(date('Y', $mixed), date('n', $mixed), date('j', $mixed));
- $arg->setTime(date('G', $mixed), date('i', $mixed), date('s', $mixed));
+ $arg->setTimestamp($mixed);
}
else
{
$arg = (int) $mixed;
}
- $range[] = $from->format($format);
- if (is_int($arg)) // Day intervals
+ $period = new DatePeriod($from, new DateInterval('P1D'), $arg);
+ foreach ($period as $date)
{
- do
- {
- $from->modify('+1 day');
- $range[] = $from->format($format);
- }
- while (--$arg > 0);
+ $range[] = $date->format($format);
}
- else // end date UNIX timestamp
- {
- for ($from->modify('+1 day'), $end_check = $arg->format('Ymd'); $from->format('Ymd') < $end_check; $from->modify('+1 day'))
- {
- $range[] = $from->format($format);
- }
- // Our loop only appended dates prior to our end date
+ /* If a period end date was passed to the DatePeriod constructor, it might not
+ * be in our results. Not sure if this is a bug or it's just possible because
+ * the end date might actually be less than 24 hours away from the previously
+ * generated DateTime object, but either way - we have to append it manually.
+ */
+ if ( ! is_int($arg) && $range[count($range) - 1] !== $arg->format($format))
+ {
$range[] = $arg->format($format);
}
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index e9f69f065..50d0cd04e 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1468,7 +1468,8 @@ class CI_Email {
.'Content-Type: '.$this->_attachments[$i]['type'].'; name="'.$name.'"'.$this->newline
.'Content-Disposition: '.$this->_attachments[$i]['disposition'].';'.$this->newline
.'Content-Transfer-Encoding: base64'.$this->newline
- .(empty($this->_attachments[$i]['cid']) ? '' : 'Content-ID: <'.$this->_attachments[$i]['cid'].'>'.$this->newline.$this->newline)
+ .(empty($this->_attachments[$i]['cid']) ? '' : 'Content-ID: <'.$this->_attachments[$i]['cid'].'>'.$this->newline)
+ .$this->newline
.$this->_attachments[$i]['content'].$this->newline;
}
@@ -1514,14 +1515,7 @@ class CI_Email {
// which only works with "\n".
if ($this->crlf === "\r\n")
{
- if (is_php('5.3'))
- {
- return quoted_printable_encode($str);
- }
- elseif (function_exists('imap_8bit'))
- {
- return imap_8bit($str);
- }
+ return quoted_printable_encode($str);
}
// Reduce multiple spaces & remove nulls
diff --git a/system/libraries/Encryption.php b/system/libraries/Encryption.php
index a10a5c20c..06284c2ed 100644
--- a/system/libraries/Encryption.php
+++ b/system/libraries/Encryption.php
@@ -152,10 +152,8 @@ class CI_Encryption {
public function __construct(array $params = array())
{
$this->_drivers = array(
- 'mcrypt' => defined('MCRYPT_DEV_URANDOM'),
- // While OpenSSL is available for PHP 5.3.0, an IV parameter
- // for the encrypt/decrypt functions is only available since 5.3.3
- 'openssl' => (is_php('5.3.3') && extension_loaded('openssl'))
+ 'mcrypt' => defined('MCRYPT_DEV_URANDOM'),
+ 'openssl' => extension_loaded('openssl')
);
if ( ! $this->_drivers['mcrypt'] && ! $this->_drivers['openssl'])
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index d5f67d1da..61f0298fd 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -1216,18 +1216,7 @@ class CI_Form_validation {
$str = 'ipv6.host'.substr($str, strlen($matches[1]) + 2);
}
- $str = 'http://'.$str;
-
- // There's a bug affecting PHP 5.2.13, 5.3.2 that considers the
- // underscore to be a valid hostname character instead of a dash.
- // Reference: https://bugs.php.net/bug.php?id=51192
- if (version_compare(PHP_VERSION, '5.2.13', '==') OR version_compare(PHP_VERSION, '5.3.2', '=='))
- {
- sscanf($str, 'http://%[^/]', $host);
- $str = substr_replace($str, strtr($host, array('_' => '-', '-' => '_')), 7, strlen($host));
- }
-
- return (filter_var($str, FILTER_VALIDATE_URL) !== FALSE);
+ return (filter_var('http://'.$str, FILTER_VALIDATE_URL) !== FALSE);
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 24fe8c68d..7ec8ba365 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -886,7 +886,7 @@ class CI_Image_lib {
}
}
- $cmd .= ' "'.escapeshellarg($this->full_src_path).'" "'.escapeshellarg($this->full_dst_path).'" 2>&1';
+ $cmd .= escapeshellarg($this->full_src_path).' '.escapeshellarg($this->full_dst_path).' 2>&1';
$retval = 1;
// exec() might be disabled
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index 316c94ae3..3e2107e83 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -288,10 +288,7 @@ class CI_Migration {
$this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class);
return FALSE;
}
- // method_exists() returns true for non-public methods,
- // while is_callable() can't be used without instantiating.
- // Only get_class_methods() satisfies both conditions.
- elseif ( ! in_array($method, array_map('strtolower', get_class_methods($class))))
+ elseif ( ! is_callable(array($class, $method)))
{
$this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class);
return FALSE;
diff --git a/system/libraries/Session/drivers/Session_files_driver.php b/system/libraries/Session/drivers/Session_files_driver.php
index 57c3777a2..bf4df8b20 100644
--- a/system/libraries/Session/drivers/Session_files_driver.php
+++ b/system/libraries/Session/drivers/Session_files_driver.php
@@ -149,18 +149,9 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
// which re-reads session data
if ($this->_file_handle === NULL)
{
- // Just using fopen() with 'c+b' mode would be perfect, but it is only
- // available since PHP 5.2.6 and we have to set permissions for new files,
- // so we'd have to hack around this ...
- if (($this->_file_new = ! file_exists($this->_file_path.$session_id)) === TRUE)
- {
- if (($this->_file_handle = fopen($this->_file_path.$session_id, 'w+b')) === FALSE)
- {
- log_message('error', "Session: File '".$this->_file_path.$session_id."' doesn't exist and cannot be created.");
- return $this->_failure;
- }
- }
- elseif (($this->_file_handle = fopen($this->_file_path.$session_id, 'r+b')) === FALSE)
+ $this->_file_new = ! file_exists($this->_file_path.$session_id);
+
+ if (($this->_file_handle = fopen($this->_file_path.$session_id, 'c+b')) === FALSE)
{
log_message('error', "Session: Unable to open file '".$this->_file_path.$session_id."'.");
return $this->_failure;
diff --git a/system/libraries/Session/drivers/Session_memcached_driver.php b/system/libraries/Session/drivers/Session_memcached_driver.php
index 88eb4b3a6..99b4d1baa 100644
--- a/system/libraries/Session/drivers/Session_memcached_driver.php
+++ b/system/libraries/Session/drivers/Session_memcached_driver.php
@@ -209,10 +209,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
$this->_memcached->replace($this->_lock_key, time(), 300);
if ($this->_fingerprint !== ($fingerprint = md5($session_data)))
{
- if (
- $this->_memcached->replace($key, $session_data, $this->_config['expiration'])
- OR ($this->_memcached->getResultCode() === Memcached::RES_NOTFOUND && $this->_memcached->set($key, $session_data, $this->_config['expiration']))
- )
+ if ($this->_memcached->set($key, $session_data, $this->_config['expiration']))
{
$this->_fingerprint = $fingerprint;
return $this->_success;
@@ -220,8 +217,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
return $this->_fail();
}
-
- if (
+ elseif (
$this->_memcached->touch($key, $this->_config['expiration'])
OR ($this->_memcached->getResultCode() === Memcached::RES_NOTFOUND && $this->_memcached->set($key, $session_data, $this->_config['expiration']))
)
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 056f6de1e..a8cf75264 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -1086,13 +1086,7 @@ class CI_Upload {
if (memory_get_usage() && ($memory_limit = ini_get('memory_limit')))
{
$memory_limit *= 1024 * 1024;
-
- // There was a bug/behavioural change in PHP 5.2, where numbers over one million get output
- // into scientific notation. number_format() ensures this number is an integer
- // http://bugs.php.net/bug.php?id=43053
-
- $memory_limit = number_format(ceil(filesize($file) + $memory_limit), 0, '.', '');
-
+ $memory_limit = (int) ceil(filesize($file) + $memory_limit);
ini_set('memory_limit', $memory_limit); // When an integer is used, the value is measured in bytes. - PHP.net
}
@@ -1207,28 +1201,21 @@ class CI_Upload {
// We'll need this to validate the MIME info string (e.g. text/plain; charset=us-ascii)
$regexp = '/^([a-z\-]+\/[a-z0-9\-\.\+]+)(;\s.+)?$/';
- /* Fileinfo extension - most reliable method
- *
- * Unfortunately, prior to PHP 5.3 - it's only available as a PECL extension and the
- * more convenient FILEINFO_MIME_TYPE flag doesn't exist.
- */
- if (function_exists('finfo_file'))
+ // Fileinfo extension - most reliable method
+ $finfo = @finfo_open(FILEINFO_MIME);
+ if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system
{
- $finfo = @finfo_open(FILEINFO_MIME);
- if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system
+ $mime = @finfo_file($finfo, $file['tmp_name']);
+ finfo_close($finfo);
+
+ /* According to the comments section of the PHP manual page,
+ * it is possible that this function returns an empty string
+ * for some files (e.g. if they don't exist in the magic MIME database)
+ */
+ if (is_string($mime) && preg_match($regexp, $mime, $matches))
{
- $mime = @finfo_file($finfo, $file['tmp_name']);
- finfo_close($finfo);
-
- /* According to the comments section of the PHP manual page,
- * it is possible that this function returns an empty string
- * for some files (e.g. if they don't exist in the magic MIME database)
- */
- if (is_string($mime) && preg_match($regexp, $mime, $matches))
- {
- $this->file_type = $matches[1];
- return;
- }
+ $this->file_type = $matches[1];
+ return;
}
}
diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php
index 8240d2340..b4e56bdae 100644
--- a/tests/Bootstrap.php
+++ b/tests/Bootstrap.php
@@ -1,10 +1,4 @@
<?php
-// For some reason, setting this fixes the 5.2 tests but breaks the 5.3 ones ...
-if (version_compare(PHP_VERSION, '5.3.0', '<'))
-{
- ini_set('memory_limit', '128M');
-}
-
// Errors on full!
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index db5088d80..c1c4997c4 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -291,7 +291,7 @@ class Loader_test extends CI_TestCase {
$this->assertEquals($content.$value, $out);
// Mock output class
- $output = $this->getMock('CI_Output', array('append_output'));
+ $output = $this->getMockBuilder('CI_Output')->setMethods(array('append_output'))->getMock();
$output->expects($this->once())->method('append_output')->with($content.$value);
$this->ci_instance_var('output', $output);
@@ -441,7 +441,7 @@ class Loader_test extends CI_TestCase {
{
// Mock lang class and test load call
$file = 'test';
- $lang = $this->getMock('CI_Lang', array('load'));
+ $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock();
$lang->expects($this->once())->method('load')->with($file);
$this->ci_instance_var('lang', $lang);
$this->assertInstanceOf('CI_Loader', $this->load->language($file));
diff --git a/tests/codeigniter/core/Log_test.php b/tests/codeigniter/core/Log_test.php
index 2dd9d90d2..d5a6fcb6b 100644
--- a/tests/codeigniter/core/Log_test.php
+++ b/tests/codeigniter/core/Log_test.php
@@ -3,11 +3,6 @@ class Log_test extends CI_TestCase {
public function test_configuration()
{
- if ( ! is_php('5.3'))
- {
- return $this->markTestSkipped("PHP 5.2 doesn't have ReflectionProperty::setAccessible() and can't run this test");
- }
-
$path = new ReflectionProperty('CI_Log', '_log_path');
$path->setAccessible(TRUE);
$threshold = new ReflectionProperty('CI_Log', '_threshold');
@@ -54,11 +49,6 @@ class Log_test extends CI_TestCase {
public function test_format_line()
{
- if ( ! is_php('5.3'))
- {
- return $this->markTestSkipped("PHP 5.2 doesn't have ReflectionProperty::setAccessible() and can't run this test");
- }
-
$this->ci_set_config('log_path', '');
$this->ci_set_config('log_threshold', 0);
$instance = new CI_Log();
diff --git a/tests/codeigniter/core/compat/password_test.php b/tests/codeigniter/core/compat/password_test.php
index 8a507d14a..77f5eba4e 100644
--- a/tests/codeigniter/core/compat/password_test.php
+++ b/tests/codeigniter/core/compat/password_test.php
@@ -8,11 +8,6 @@ class password_test extends CI_TestCase {
{
return $this->markTestSkipped('ext/standard/password is available on PHP 5.5');
}
- elseif ( ! is_php('5.3.7'))
- {
- $this->assertFalse(defined('PASSWORD_BCRYPT'));
- return $this->markTestSkipped("PHP versions prior to 5.3.7 don't have the '2y' Blowfish version");
- }
// defined as of HHVM 2.3.0, which is also when they introduce password_*() as well
// Note: Do NOT move this after the CRYPT_BLOWFISH check
elseif (defined('HHVM_VERSION'))
diff --git a/tests/codeigniter/core/compat/standard_test.php b/tests/codeigniter/core/compat/standard_test.php
index 4077a5c7c..a98460129 100644
--- a/tests/codeigniter/core/compat/standard_test.php
+++ b/tests/codeigniter/core/compat/standard_test.php
@@ -15,13 +15,6 @@ class standard_test extends CI_TestCase {
{
$this->assertTrue(function_exists('hex2bin'));
}
-
- if ( ! is_php('5.3'))
- {
- $this->assertTrue(function_exists('array_replace'));
- $this->assertTrue(function_exists('array_replace_recursive'));
- $this->assertTrue(function_exists('quoted_printable_encode'));
- }
}
// ------------------------------------------------------------------------
@@ -356,193 +349,6 @@ class standard_test extends CI_TestCase {
$this->assertEquals('', hex2bin(''));
$this->assertEquals("\x01\x02\x03", hex2bin(new FooHex()));
}
-
- // ------------------------------------------------------------------------
-
- /**
- * array_replace(), array_replace_recursive() tests
- *
- * Borrowed from PHP's own tests
- *
- * @depends test_bootstrap
- */
- public function test_array_replace_recursive()
- {
- if (is_php('5.3'))
- {
- return $this->markTestSkipped('array_replace() and array_replace_recursive() are already available on PHP 5.3');
- }
-
- $array1 = array(
- 0 => 'dontclobber',
- '1' => 'unclobbered',
- 'test2' => 0.0,
- 'test3' => array(
- 'testarray2' => TRUE,
- 1 => array(
- 'testsubarray1' => 'dontclobber2',
- 'testsubarray2' => 'dontclobber3'
- )
- )
- );
-
- $array2 = array(
- 1 => 'clobbered',
- 'test3' => array(
- 'testarray2' => FALSE
- ),
- 'test4' => array(
- 'clobbered3' => array(0, 1, 2)
- )
- );
-
- // array_replace()
- $this->assertEquals(
- array(
- 0 => 'dontclobber',
- 1 => 'clobbered',
- 'test2' => 0.0,
- 'test3' => array(
- 'testarray2' => FALSE
- ),
- 'test4' => array(
- 'clobbered3' => array(0, 1, 2)
- )
- ),
- array_replace($array1, $array2)
- );
-
- // array_replace_recursive()
- $this->assertEquals(
- array(
- 0 => 'dontclobber',
- 1 => 'clobbered',
- 'test2' => 0.0,
- 'test3' => array(
- 'testarray2' => FALSE,
- 1 => array(
- 'testsubarray1' => 'dontclobber2',
- 'testsubarray2' => 'dontclobber3'
- )
- ),
- 'test4' => array(
- 'clobbered3' => array(0, 1, 2)
- )
- ),
- array_replace_recursive($array1, $array2)
- );
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * quoted_printable_encode() tests
- *
- * Borrowed from PHP's own tests
- *
- * @depends test_bootstrap
- */
- public function test_quoted_printable_encode()
- {
- if (is_php('5.3'))
- {
- return $this->markTestSkipped('quoted_printable_encode() is already available on PHP 5.3');
- }
-
- // These are actually imap_8bit() tests:
- $this->assertEquals("String with CRLF at end=20\r\n", quoted_printable_encode("String with CRLF at end \r\n"));
- // ext/imap/tests/imap_8bit_basic.phpt says for this line:
- // NB this appears to be a bug in cclient; a space at end of string should be encoded as =20
- $this->assertEquals("String with space at end ", quoted_printable_encode("String with space at end "));
- $this->assertEquals("String with tabs =09=09 in middle", quoted_printable_encode("String with tabs \t\t in middle"));
- $this->assertEquals("String with tab at end =09", quoted_printable_encode("String with tab at end \t"));
- $this->assertEquals("=00=01=02=03=04=FE=FF=0A=0D", quoted_printable_encode("\x00\x01\x02\x03\x04\xfe\xff\x0a\x0d"));
-
- if (function_exists('imap_8bit'))
- {
- return $this->markTestIncomplete('imap_8bit() exists and is called as an alias for quoted_printable_encode()');
- }
-
- // And these are from ext/standard/tests/strings/quoted_printable_encode_002.phpt:
- $this->assertEquals(
- "=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
- ."=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00",
- $d = quoted_printable_encode(str_repeat("\0", 200))
- );
- $this->assertEquals(str_repeat("\x0", 200), quoted_printable_decode($d));
- $this->assertEquals(
- "=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=\r\n"
- ."=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=\r\n"
- ."=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=\r\n"
- ."=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=\r\n"
- ."=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=\r\n"
- ."=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=\r\n"
- ."=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=\r\n"
- ."=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D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=BA=D0=B0 =D0=B2 =D1=\r\n"
- ."=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5",
- $d = quoted_printable_encode(str_repeat('строка в юникоде', 50))
- );
- $this->assertEquals(str_repeat('строка в юникоде', 50), quoted_printable_decode($d));
- $this->assertEquals('this is a foo', quoted_printable_encode(new FooObject()));
- }
}
// ------------------------------------------------------------------------
@@ -570,11 +376,3 @@ class FooHex {
return '010203';
}
}
-
-class FooObject
-{
- public function __toString()
- {
- return 'this is a foo';
- }
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php
index c80e92cd0..c4f99a97c 100644
--- a/tests/codeigniter/helpers/date_helper_test.php
+++ b/tests/codeigniter/helpers/date_helper_test.php
@@ -15,7 +15,7 @@ class Date_helper_test extends CI_TestCase {
/*
// This stub job, is simply to cater $config['time_reference']
- $config = $this->getMock('CI_Config');
+ $config = $this->getMockBuilder('CI_Config')->getMock();
$config->expects($this->any())
->method('item')
->will($this->returnValue('local'));
@@ -37,7 +37,7 @@ class Date_helper_test extends CI_TestCase {
/*
// This stub job, is simply to cater $config['time_reference']
- $config = $this->getMock('CI_Config');
+ $config = $this->getMockBuilder('CI_Config')->getMock();
$config->expects($this->any())
->method('item')
->will($this->returnValue('UTC'));
diff --git a/tests/codeigniter/helpers/language_helper_test.php b/tests/codeigniter/helpers/language_helper_test.php
index 176da689a..1ddabea3d 100644
--- a/tests/codeigniter/helpers/language_helper_test.php
+++ b/tests/codeigniter/helpers/language_helper_test.php
@@ -5,7 +5,7 @@ class Language_helper_test extends CI_TestCase {
public function test_lang()
{
$this->helper('language');
- $lang = $this->getMock('CI_Lang', array('line'));
+ $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('line'))->getMock();
$lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
$this->ci_instance_var('lang', $lang);
@@ -13,4 +13,4 @@ class Language_helper_test extends CI_TestCase {
$this->assertEquals('<label for="foo" class="bar"></label>', lang(1, 'foo', array('class' => 'bar')));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php
index 817db2c7e..663e354fe 100644
--- a/tests/codeigniter/helpers/number_helper_test.php
+++ b/tests/codeigniter/helpers/number_helper_test.php
@@ -11,7 +11,7 @@ class Number_helper_test extends CI_TestCase {
// Mock away load, too much going on in there,
// we'll just check for the expected parameter
- $lang = $this->getMock($lang_cls, array('load'));
+ $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock();
$lang->expects($this->once())
->method('load')
->with($this->equalTo('number'));
@@ -60,4 +60,4 @@ class Number_helper_test extends CI_TestCase {
$this->assertEquals('112,283.3 TB', byte_format(123456789123456789));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/libraries/Calendar_test.php b/tests/codeigniter/libraries/Calendar_test.php
index 54879fec9..ad1f45e8c 100644
--- a/tests/codeigniter/libraries/Calendar_test.php
+++ b/tests/codeigniter/libraries/Calendar_test.php
@@ -5,9 +5,9 @@ class Calendar_test extends CI_TestCase {
public function set_up()
{
// Required for get_total_days()
- $this->ci_instance_var('load', $this->getMock('CI_Loader', array('helper')));
+ $this->ci_instance_var('load', $this->getMockBuilder('CI_Loader')->setMethods(array('helper'))->getMock());
- $lang = $this->getMock('CI_Lang', array('load', 'line'));
+ $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load', 'line'))->getMock();
$lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
$this->ci_instance_var('lang', $lang);
@@ -219,4 +219,4 @@ class Calendar_test extends CI_TestCase {
$this->assertEquals($array, $this->calendar->default_template());
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/libraries/Driver_test.php b/tests/codeigniter/libraries/Driver_test.php
index c62cbee45..e4401e688 100644
--- a/tests/codeigniter/libraries/Driver_test.php
+++ b/tests/codeigniter/libraries/Driver_test.php
@@ -16,7 +16,7 @@ class Driver_test extends CI_TestCase {
// Mock Loader->get_package_paths
$paths = 'get_package_paths';
- $ldr = $this->getMock('CI_Loader', array($paths));
+ $ldr = $this->getMockBuilder('CI_Loader')->setMethods(array($paths))->getMock();
$ldr->expects($this->any())->method($paths)->will($this->returnValue(array(APPPATH, BASEPATH)));
$this->ci_instance_var('load', $ldr);
@@ -175,4 +175,4 @@ class Driver_test extends CI_TestCase {
$this->assertEquals($return, $child->$method());
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php
index b87ca65ff..0815300e6 100644
--- a/tests/codeigniter/libraries/Form_validation_test.php
+++ b/tests/codeigniter/libraries/Form_validation_test.php
@@ -8,10 +8,10 @@ class Form_validation_test extends CI_TestCase {
// Create a mock loader since load->helper() looks in the wrong directories for unit tests,
// We'll use CI_TestCase->helper() instead
- $loader = $this->getMock('CI_Loader', array('helper'));
+ $loader = $this->getMockBuilder('CI_Loader')->setMethods(array('helper'))->getMock();
// Same applies for lang
- $lang = $this->getMock('CI_Lang', array('load'));
+ $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock();
$this->ci_set_config('charset', 'UTF-8');
$utf8 = new Mock_Core_Utf8();
@@ -259,6 +259,9 @@ class Form_validation_test extends CI_TestCase {
// https://github.com/bcit-ci/CodeIgniter/issues/4415
$this->assertTrue($this->form_validation->valid_url('http://[::1]/ipv6'));
+ // URI scheme case-sensitivity: https://github.com/bcit-ci/CodeIgniter/pull/4758
+ $this->assertTrue($this->form_validation->valid_url('HtTp://127.0.0.1/'));
+
$this->assertFalse($this->form_validation->valid_url('htt://www.codeIgniter.com'));
$this->assertFalse($this->form_validation->valid_url(''));
$this->assertFalse($this->form_validation->valid_url('code igniter'));
diff --git a/tests/codeigniter/libraries/Upload_test.php b/tests/codeigniter/libraries/Upload_test.php
index 4fbc11ef0..8bac597b3 100644
--- a/tests/codeigniter/libraries/Upload_test.php
+++ b/tests/codeigniter/libraries/Upload_test.php
@@ -7,7 +7,7 @@ class Upload_test extends CI_TestCase {
$ci = $this->ci_instance();
$ci->upload = new CI_Upload();
$ci->security = new Mock_Core_Security();
- $ci->lang = $this->getMock('CI_Lang', array('load', 'line'));
+ $ci->lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load', 'line'))->getMock();
$ci->lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
$this->upload = $ci->upload;
}
@@ -25,14 +25,10 @@ class Upload_test extends CI_TestCase {
)
);
- // ReflectionProperty::setAccessible() is not available in PHP 5.2.x
- if (is_php('5.3'))
- {
- $reflection = new ReflectionClass($upload);
- $reflection = $reflection->getProperty('_file_name_override');
- $reflection->setAccessible(TRUE);
- $this->assertEquals('foo', $reflection->getValue($upload));
- }
+ $reflection = new ReflectionClass($upload);
+ $reflection = $reflection->getProperty('_file_name_override');
+ $reflection->setAccessible(TRUE);
+ $this->assertEquals('foo', $reflection->getValue($upload));
$this->assertTrue($upload->file_ext_tolower);
@@ -300,4 +296,4 @@ class Upload_test extends CI_TestCase {
$this->assertEquals('<p>Error test</p>', $this->upload->display_errors());
}
-} \ No newline at end of file
+}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index f9e7f572c..26587ad3e 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -48,8 +48,12 @@ Release Date: Not Released
Bug fixes for 3.1.1
-------------------
-
-
+- Fixed a bug (#4732) - :doc:`Session Library <libraries/sessions>` triggered errors while writing data for a newly-created sessions with the 'memcached' driver.
+- Fixed a regression (#4736) - :doc:`Image Manipulation Library <libraries/image_lib>` processing via ImageMagick didn't work.
+- Fixed a bug (#4737) - :doc:`Query Builder <database/query_builder>` didn't add an ``OFFSET`` when ``LIMIT`` is zero or unused.
+- Fixed a regression (#4739) - :doc:`Email Library <libraries/email>` doesn't properly separate attachment bodies from headers.
+- Fixed a bug (#4754) - :doc:`Unit Testing Library <libraries/unit_testing>` method ``result()`` didn't translate ``res_datatype``.
+- Fixed a bug (#4759) - :doc:`Form Validation <libraries/form_validation>`, :doc:`Trackback <libraries/trackback>` and `XML-RPC <libraries/xmlrpc>` libraries treated URI schemes in a case-sensitive manner.
Version 3.1.0
=============
diff --git a/user_guide_src/source/general/compatibility_functions.rst b/user_guide_src/source/general/compatibility_functions.rst
index 434b0982f..936f2a24b 100644
--- a/user_guide_src/source/general/compatibility_functions.rst
+++ b/user_guide_src/source/general/compatibility_functions.rst
@@ -222,29 +222,6 @@ Function reference
For more information, please refer to the `PHP manual for
array_column() <http://php.net/array_column>`_.
-.. php:function:: array_replace(array $array1[, ...])
-
- :param array $array1: Array in which to replace elements
- :param array ...: Array (or multiple ones) from which to extract elements
- :returns: Modified array
- :rtype: array
-
- For more information, please refer to the `PHP manual for
- array_replace() <http://php.net/array_replace>`_.
-
-.. php:function:: array_replace_recursive(array $array1[, ...])
-
- :param array $array1: Array in which to replace elements
- :param array ...: Array (or multiple ones) from which to extract elements
- :returns: Modified array
- :rtype: array
-
- For more information, please refer to the `PHP manual for
- array_replace_recursive() <http://php.net/array_replace_recursive>`_.
-
- .. important:: Only PHP's native function can detect endless recursion.
- Unless you are running PHP 5.3+, be careful with references!
-
.. php:function:: hex2bin($data)
:param array $data: Hexadecimal representation of data
@@ -253,12 +230,3 @@ Function reference
For more information, please refer to the `PHP manual for hex2bin()
<http://php.net/hex2bin>`_.
-
-.. php:function:: quoted_printable_encode($str)
-
- :param string $str: Input string
- :returns: 8bit-encoded string
- :rtype: string
-
- For more information, please refer to the `PHP manual for
- quoted_printable_encode() <http://php.net/quoted_printable_encode>`_. \ No newline at end of file
diff --git a/user_guide_src/source/general/hooks.rst b/user_guide_src/source/general/hooks.rst
index ffe3fef39..6cc3407a3 100644
--- a/user_guide_src/source/general/hooks.rst
+++ b/user_guide_src/source/general/hooks.rst
@@ -56,8 +56,8 @@ defined in your associative hook array:
- **params** Any parameters you wish to pass to your script. This item
is optional.
-If you're running PHP 5.3+, you can also use lambda/anoymous functions
-(or closures) as hooks, with a simpler syntax::
+You can also use lambda/anoymous functions (or closures) as hooks, with
+a simpler syntax::
$hook['post_controller'] = function()
{
diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst
index 515368099..b53a85d31 100644
--- a/user_guide_src/source/general/routing.rst
+++ b/user_guide_src/source/general/routing.rst
@@ -133,8 +133,8 @@ might be a good starting point.
Callbacks
=========
-If you are using PHP >= 5.3 you can use callbacks in place of the normal
-routing rules to process the back-references. Example::
+You can also use callbacks in place of the normal routing rules to process
+the back-references. Example::
$route['products/([a-zA-Z]+)/edit/(\d+)'] = function ($product_type, $id)
{
diff --git a/user_guide_src/source/general/security.rst b/user_guide_src/source/general/security.rst
index 8afdaca31..744a2c934 100644
--- a/user_guide_src/source/general/security.rst
+++ b/user_guide_src/source/general/security.rst
@@ -133,12 +133,7 @@ with that. Please read below.
in PHP's own `Password Hashing <http://php.net/password>`_ functions.
Please use them, even if you're not running PHP 5.5+, CodeIgniter
- provides them for you as long as you're running at least PHP version
- 5.3.7 (and if you don't meet that requirement - please, upgrade).
-
- If you're one of the really unlucky people who can't even upgrade to a
- more recent PHP version, use `hash_pbkdf() <http://php.net/hash_pbkdf2>`,
- which we also provide in our compatibility layer.
+ provides them for you.
- DO NOT ever display or send a password in plain-text format!
diff --git a/user_guide_src/source/libraries/encryption.rst b/user_guide_src/source/libraries/encryption.rst
index cac4b7921..377e650a9 100644
--- a/user_guide_src/source/libraries/encryption.rst
+++ b/user_guide_src/source/libraries/encryption.rst
@@ -13,7 +13,7 @@ unfortunately not always available on all systems.
You must meet one of the following dependencies in order to use this
library:
-- `OpenSSL <http://php.net/openssl>`_ (and PHP 5.3.3)
+- `OpenSSL <http://php.net/openssl>`_
- `MCrypt <http://php.net/mcrypt>`_ (and `MCRYPT_DEV_URANDOM` availability)
If neither of the above dependencies is met, we simply cannot offer
diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst
index b03b544e2..5b9a74273 100644
--- a/user_guide_src/source/libraries/form_validation.rst
+++ b/user_guide_src/source/libraries/form_validation.rst
@@ -495,8 +495,7 @@ The above code would use the ``valid_username()`` method from your
This is just an example of course, and callbacks aren't limited to models.
You can use any object/method that accepts the field value as its' first
-parameter. Or if you're running PHP 5.3+, you can also use an anonymous
-function::
+parameter. You can also use an anonymous function::
$this->form_validation->set_rules(
'username', 'Username',
@@ -522,7 +521,7 @@ the second element of an array, with the first one being the rule name::
)
);
-Anonymous function (PHP 5.3+) version::
+Anonymous function version::
$this->form_validation->set_rules(
'username', 'Username',