Skip to content

Commit

Permalink
php8.4: add patches for codeigniter
Browse files Browse the repository at this point in the history
  • Loading branch information
tenzap committed Nov 27, 2024
1 parent 0819854 commit 3539807
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 1 deletion.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
"patches": {
"codeigniter/framework": {
"Add support for PHP 8.2 (part1)": "patches/Codeigniter_Framework/v3.1.13/10-php82_support.patch",
"Add support for PHP 8.2 (part2)": "patches/Codeigniter_Framework/v3.1.13/10-php82_support-part2.patch"
"Add support for PHP 8.2 (part2)": "patches/Codeigniter_Framework/v3.1.13/10-php82_support-part2.patch",
"Add support for PHP 8.4 (E_STRICT)": "patches/Codeigniter_Framework/v3.1.13/11-php84_support_E_STRICT.patch",
"Add support for PHP 8.4 (implicit nullable type)": "patches/Codeigniter_Framework/v3.1.13/11-php84_support_fix_implicit_nullable_type_error.patch",
"Add support for PHP 8.4 (session sid)": "patches/Codeigniter_Framework/v3.1.13/11-php84_support_session.sid_length_INI_setting_is_deprecated.patch"
},
"kenjis/ci-phpunit-test": {
"Add support for PHP 8.2": "patches/Kenjis_CiPhpunitTest/v3.0.4/support_php-8.2.patch"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Description: remove deprecation notice on php8.4 for E_STRICT
From 831108645a2b68150471035a7e5ced5086da2c51 Mon Sep 17 00:00:00 2001
From: Bruno Moreira <git@pocketarc.com>
From: Fab Stz <fabstz-it@yahoo.fr>
Origin: https://github.com/pocketarc/codeigniter/commit/831108645a2b68150471035a7e5ced5086da2c51
Date: Tue, 29 Oct 2024 06:12:23 -0600
Bug: https://github.com/bcit-ci/CodeIgniter/issues/6301

--- a/index.php
+++ b/index.php
@@ -73,7 +73,11 @@
case 'testing':
case 'production':
ini_set('display_errors', 0);
- if (version_compare(PHP_VERSION, '5.3', '>='))
+ if (version_compare(PHP_VERSION, '8.4', '>='))
+ {
+ error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
+ }
+ else if (version_compare(PHP_VERSION, '5.3', '>='))
{
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
}
--- a/system/core/Exceptions.php
+++ b/system/core/Exceptions.php
@@ -73,7 +73,11 @@
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
- E_STRICT => 'Runtime Notice'
+
+ # 2048 is E_STRICT, but it's deprecated in PHP 8.4.
+ # We're keeping this here for backwards compatibility.
+ # If we're on older PHP, E_STRICT errors will be labelled correctly, and if we're on PHP 8.4+, this will be ignored.
+ 2048 => 'Runtime Notice'
);

/**
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Origin: https://github.com/pocketarc/codeigniter/commit/d310726565c12ba99b8037e8fb231ed739258e6e
Bug: https://github.com/bcit-ci/CodeIgniter/issues/6302
From d310726565c12ba99b8037e8fb231ed739258e6e Mon Sep 17 00:00:00 2001
From: Bruno Moreira <git@pocketarc.com>
Date: Tue, 29 Oct 2024 06:34:00 -0600
Subject: [PATCH] Fixes a few more PHP 8.4 compatibility issues.
Last-Update: 2024-10-30

--- a/system/libraries/Encryption.php
+++ b/system/libraries/Encryption.php
@@ -366,10 +366,10 @@
* Encrypt
*
* @param string $data Input data
- * @param array $params Input parameters
+ * @param array|null $params Input parameters
* @return string
*/
- public function encrypt($data, array $params = NULL)
+ public function encrypt($data, $params = NULL)
{
if (($params = $this->_get_params($params)) === FALSE)
{
@@ -501,10 +501,10 @@
* Decrypt
*
* @param string $data Encrypted data
- * @param array $params Input parameters
+ * @param array|null $params Input parameters
* @return string
*/
- public function decrypt($data, array $params = NULL)
+ public function decrypt($data, $params = NULL)
{
if (($params = $this->_get_params($params)) === FALSE)
{
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Description: skip deprecated setting of session.sid_length on php8.4
On php 8.4, this will use the default values of php 8.4
as per the recommended way to do it.
Bug: https://github.com/bcit-ci/CodeIgniter/issues/6300
Author: Fab Stz <fabstz-it@yahoo.fr>
Last-Update: 2024-10-15

--- a/system/libraries/Session/Session.php
+++ b/system/libraries/Session/Session.php
@@ -419,7 +419,7 @@
{
$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)
+ if (($bits = $sid_length * $bits_per_character) < 160 && PHP_VERSION_ID < 80400)
{
// Add as many more characters as necessary to reach at least 160 bits
$sid_length += (int) ceil((160 % $bits) / $bits_per_character);

0 comments on commit 3539807

Please sign in to comment.