Skip to content

Commit

Permalink
Remove dead code written for PHP 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
narfbg committed Jul 28, 2016
1 parent 1748567 commit a838279
Show file tree
Hide file tree
Showing 25 changed files with 55 additions and 649 deletions.
6 changes: 1 addition & 5 deletions system/core/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,7 @@ function &get_instance()
$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;
}
Expand Down
7 changes: 1 addition & 6 deletions system/core/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -678,12 +678,7 @@ public function entity_decode($str, $charset = NULL)
{
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
Expand Down
2 changes: 1 addition & 1 deletion system/core/compat/password.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

// ------------------------------------------------------------------------

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;
}
Expand Down
207 changes: 0 additions & 207 deletions system/core/compat/standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,210 +180,3 @@ function hex2bin($data)
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;
}
}
7 changes: 3 additions & 4 deletions system/database/drivers/mysqli/mysqli_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ public function db_connect($persistent = FALSE)
}
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;
Expand Down Expand Up @@ -502,8 +501,8 @@ public function error()
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
);
}

Expand Down
2 changes: 1 addition & 1 deletion system/database/drivers/oci8/oci8_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ protected function _bind_params($params)
*/
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;
}

Expand Down
16 changes: 2 additions & 14 deletions system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function __construct($params)
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;
}
Expand All @@ -122,17 +122,6 @@ public function __construct($params)
*/
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)
Expand Down Expand Up @@ -169,8 +158,7 @@ public function db_connect($persistent = FALSE)
$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'];
Expand Down
Loading

0 comments on commit a838279

Please sign in to comment.