Skip to content

Commit

Permalink
PHP8.4 deprecation notices fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
NielBuys committed Sep 30, 2024
1 parent 84f0752 commit 165e228
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 59 deletions.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
case 'testing':
case 'production':
ini_set('display_errors', 0);
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
break;

default:
Expand Down
3 changes: 1 addition & 2 deletions system/core/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ class CI_Exceptions {
E_COMPILE_WARNING => 'Compile Warning',
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Runtime Notice'
E_USER_NOTICE => 'User Notice'
);

/**
Expand Down
4 changes: 2 additions & 2 deletions system/libraries/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public function create_key($length)
* @param array $params Input parameters
* @return string
*/
public function encrypt($data, array $params = NULL)
public function encrypt($data, ?array $params = NULL)
{
if (($params = $this->_get_params($params)) === FALSE)
{
Expand Down Expand Up @@ -504,7 +504,7 @@ protected function _openssl_encrypt($data, $params)
* @param array $params Input parameters
* @return string
*/
public function decrypt($data, array $params = NULL)
public function decrypt($data, ?array $params = NULL)
{
if (($params = $this->_get_params($params)) === FALSE)
{
Expand Down
67 changes: 14 additions & 53 deletions system/libraries/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,59 +389,20 @@ protected function _configure(&$params)
*/
protected function _configure_sid_length()
{
if (PHP_VERSION_ID < 70100)
{
$hash_function = ini_get('session.hash_function');
if (ctype_digit((string) $hash_function))
{
if ($hash_function !== '1')
{
ini_set('session.hash_function', 1);
}

$bits = 160;
}
elseif ( ! in_array($hash_function, hash_algos(), TRUE))
{
ini_set('session.hash_function', 1);
$bits = 160;
}
elseif (($bits = strlen(hash($hash_function, 'dummy', false)) * 4) < 160)
{
ini_set('session.hash_function', 1);
$bits = 160;
}

$bits_per_character = (int) ini_get('session.hash_bits_per_character');
$sid_length = (int) ceil($bits / $bits_per_character);
}
else
{
$bits_per_character = (int) ini_get('session.sid_bits_per_character');
$sid_length = (int) ini_get('session.sid_length');
if (($bits = $sid_length * $bits_per_character) < 160)
{
// Add as many more characters as necessary to reach at least 160 bits
$sid_length += (int) ceil((160 % $bits) / $bits_per_character);
ini_set('session.sid_length', $sid_length);
}
}

// Yes, 4,5,6 are the only known possible values as of 2016-10-27
switch ($bits_per_character)
{
case 4:
$this->_sid_regexp = '[0-9a-f]';
break;
case 5:
$this->_sid_regexp = '[0-9a-v]';
break;
case 6:
$this->_sid_regexp = '[0-9a-zA-Z,-]';
break;
}

$this->_sid_regexp .= '{'.$sid_length.'}';
$bits_per_character = (int) ini_get('session.sid_bits_per_character');
$sid_length = (int) ini_get('session.sid_length');

// We force the PHP defaults.
if (PHP_VERSION_ID < 90000) {
if ($bits_per_character !== 4) {
ini_set('session.sid_bits_per_character', '4');
}
if ($sid_length !== 32) {
ini_set('session.sid_length', '32');
}
}

$this->_sid_regexp = '[0-9a-f]{32}';
}

// ------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tests/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
// Errors on full!
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
error_reporting(E_ALL);

$dir = realpath(dirname(__FILE__));

Expand Down

0 comments on commit 165e228

Please sign in to comment.