CodeIgniter Forums
Codeigniter 2.2.x and PHP 8.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 2.x (https://forum.codeigniter.com/forumdisplay.php?fid=18)
+--- Thread: Codeigniter 2.2.x and PHP 8.0 (/showthread.php?tid=85237)



Codeigniter 2.2.x and PHP 8.0 - svenhaveman - 12-07-2022

Hi,
I am one of those guys that built a webapp ten years ago and updated it untill CodeIgniter 2.2.6.
Unfortunatly, CI 2 breaks when running PHP 8.0 and PHP 7.4 is reaching its end-of-life cycle. Upgrading to CI 3 and then to CI 4 takes a lot of time. Eventually will rewrite the whole thing, but for now i want to make things safe and running.
Because there are no official updates for 2.2.x and i'm running the webapp inside a isolated docker container in production i started hacking the core to get it working again, and thought i would share this with you.

Patch #1
File: system/core/Common.php
Error: $level is an optional argument, that is before a required argument. Depracated. I removed the optional flag and handled in the function itself.

Fix: replace the log_message function with the function inside the pastebin link
https://pastebin.com/1vEkkiEy

Patch #2
File: system/core/Input.php
Error: filter_var options argument needs to be an array or an integer. String given
Fix: Replace line 388, the default in the switch statement to $flag = array(); in stead of $flag = '';
https://pastebin.com/dDU1NjWX

This fixed it for me and got it working again. Maybe i did something stupid, maybe i forgot some other functions that i don't use, but you do, please share inside this topic to help other people get this up and running :-).

Thanks!


RE: Codeigniter 2.2.x and PHP 8.0 - InsiteFX - 12-08-2022

Your best bet would be to upgrade it to CodeIgniter v4.2.10. Because of Security issues.


RE: Codeigniter 2.2.x and PHP 8.0 - svenhaveman - 12-08-2022

I agree, need to update the entire thing. But at this time the application isn't publicly available and is on an isolated server. So i took other measures to keep it safe, for now :-)