Welcome Guest, Not a member yet? Register   Sign In
PHP8 Support for Codeigniter 2.2.6
#1
Bug 
(This post was last modified: 12-20-2023, 11:46 PM by Dialedin.)

After Upgrading PHP Version to 8 and CodeIgniter to 2.2.6:
  • Sitewide 500 Error:Identified an issue with the function valid_ip in the core file "system/core/input.php."
  • The filter_var function was called with the third param as NULL, causing an error in PHP8.
  • Cross-checked the function's code with CodeIgniter3, found they updated the code with third param passing as 0.
  • Applied the same fix in CodeIgniter2.2.6, resolving the problem.
  • The xss_clean function was causing a 500 error while processing array data from the post input.
  • Core issue in /system/core/Security.php: Rewrote the code using foreach instead of a list and each method in a while loop, resolving the problem.
Code:
Here is the patch that you can apply to fix the above issue:

diff --git a/system/core/Input.php b/system/core/Input.php
index 4030574..dfc88a8 100755
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -385,7 +385,7 @@ class CI_Input {
$flag = FILTER_FLAG_IPV6;
break;
default:
- $flag = '';
+ $flag = 0;
break;
}

diff --git a/system/core/Security.php b/system/core/Security.php
index a30488f..164e62c 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -270,11 +270,9 @@ class CI_Security {
// Is the string an array?
if (is_array($str))
{
- while (list($key) = each($str))
- {
- $str[$key] = $this->xss_clean($str[$key]);
+ foreach($str as $key => $val) {
+ $str[$key] = $this->xss_clean($val);
}
-
return $str;
}
Reply
#2

Please, stop "screwing the wheels to the ship". Version 1-3 is very old and in fact requires a full update. 

And it will turn out CI4
Reply




Theme © iAndrew 2016 - Forum software by © MyBB