Skip to content

Commit fc90b48

Browse files
authored
Merge pull request #1 from NielBuys/tasks/php8_4_deprecation_notices
PHP8.4 deprecation notices fix attempt
2 parents 84f0752 + 8c7a9a4 commit fc90b48

File tree

6 files changed

+20
-60
lines changed

6 files changed

+20
-60
lines changed

.github/workflows/test-phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [push, pull_request]
55
jobs:
66
tests:
77
runs-on: ubuntu-latest
8-
if: "!contains(github.event.head_commit.message, '[ci skip]')"
8+
if: '!contains(github.event.head_commit.message, "[ci skip]")'
99
env:
1010
PHP_INI_VALUES: assert.exception=1, zend.assertions=1
1111

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
case 'testing':
7474
case 'production':
7575
ini_set('display_errors', 0);
76-
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
76+
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
7777
break;
7878

7979
default:

system/core/Exceptions.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ class CI_Exceptions {
7272
E_COMPILE_WARNING => 'Compile Warning',
7373
E_USER_ERROR => 'User Error',
7474
E_USER_WARNING => 'User Warning',
75-
E_USER_NOTICE => 'User Notice',
76-
E_STRICT => 'Runtime Notice'
75+
E_USER_NOTICE => 'User Notice'
7776
);
7877

7978
/**

system/libraries/Encryption.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public function create_key($length)
369369
* @param array $params Input parameters
370370
* @return string
371371
*/
372-
public function encrypt($data, array $params = NULL)
372+
public function encrypt($data, ?array $params = NULL)
373373
{
374374
if (($params = $this->_get_params($params)) === FALSE)
375375
{
@@ -504,7 +504,7 @@ protected function _openssl_encrypt($data, $params)
504504
* @param array $params Input parameters
505505
* @return string
506506
*/
507-
public function decrypt($data, array $params = NULL)
507+
public function decrypt($data, ?array $params = NULL)
508508
{
509509
if (($params = $this->_get_params($params)) === FALSE)
510510
{

system/libraries/Session/Session.php

Lines changed: 14 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -389,59 +389,20 @@ protected function _configure(&$params)
389389
*/
390390
protected function _configure_sid_length()
391391
{
392-
if (PHP_VERSION_ID < 70100)
393-
{
394-
$hash_function = ini_get('session.hash_function');
395-
if (ctype_digit((string) $hash_function))
396-
{
397-
if ($hash_function !== '1')
398-
{
399-
ini_set('session.hash_function', 1);
400-
}
401-
402-
$bits = 160;
403-
}
404-
elseif ( ! in_array($hash_function, hash_algos(), TRUE))
405-
{
406-
ini_set('session.hash_function', 1);
407-
$bits = 160;
408-
}
409-
elseif (($bits = strlen(hash($hash_function, 'dummy', false)) * 4) < 160)
410-
{
411-
ini_set('session.hash_function', 1);
412-
$bits = 160;
413-
}
414-
415-
$bits_per_character = (int) ini_get('session.hash_bits_per_character');
416-
$sid_length = (int) ceil($bits / $bits_per_character);
417-
}
418-
else
419-
{
420-
$bits_per_character = (int) ini_get('session.sid_bits_per_character');
421-
$sid_length = (int) ini_get('session.sid_length');
422-
if (($bits = $sid_length * $bits_per_character) < 160)
423-
{
424-
// Add as many more characters as necessary to reach at least 160 bits
425-
$sid_length += (int) ceil((160 % $bits) / $bits_per_character);
426-
ini_set('session.sid_length', $sid_length);
427-
}
428-
}
429-
430-
// Yes, 4,5,6 are the only known possible values as of 2016-10-27
431-
switch ($bits_per_character)
432-
{
433-
case 4:
434-
$this->_sid_regexp = '[0-9a-f]';
435-
break;
436-
case 5:
437-
$this->_sid_regexp = '[0-9a-v]';
438-
break;
439-
case 6:
440-
$this->_sid_regexp = '[0-9a-zA-Z,-]';
441-
break;
442-
}
443-
444-
$this->_sid_regexp .= '{'.$sid_length.'}';
392+
$bits_per_character = (int) ini_get('session.sid_bits_per_character');
393+
$sid_length = (int) ini_get('session.sid_length');
394+
395+
// We force the PHP defaults.
396+
if (PHP_VERSION_ID < 90000) {
397+
if ($bits_per_character !== 4) {
398+
@ini_set('session.sid_bits_per_character', '4');
399+
}
400+
if ($sid_length !== 32) {
401+
@ini_set('session.sid_length', '32');
402+
}
403+
}
404+
405+
$this->_sid_regexp = '[0-9a-f]{32}';
445406
}
446407

447408
// ------------------------------------------------------------------------

tests/Bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
// Errors on full!
33
ini_set('display_errors', 1);
4-
error_reporting(E_ALL | E_STRICT);
4+
error_reporting(E_ALL);
55

66
$dir = realpath(dirname(__FILE__));
77

0 commit comments

Comments
 (0)