Welcome Guest, Not a member yet? Register   Sign In
Poll: Would you consider upgrading to PHP 8.0?
You do not have permission to vote in this poll.
Yes
89.66%
26 89.66%
No
10.34%
3 10.34%
Total 29 vote(s) 100%
* You voted for this item. [Show Results]

Surprised to see codeigniter 3.x running successfull with PHP 8.0 as well.
#5

(This post was last modified: 01-14-2021, 05:16 PM by CINewb.)

Today I installed PHP8 and tried it with our CodeIgniter 3 project.

I found 2 issues:

1) We had a controller class called Attribute which it doesn't like.  Perhaps this is a reserved word in PHP8.

2) More serious - flash data doesn't seem to clear.  Once you have a piece of flash data set, for example "Your changes were saved", it continues to persist on every page load thereafter.   I tracked this down to \system\libraries\Session\Session.php Lines 418 to 423:

Code:
// Hacky, but 'old' will (implicitly) always be less than time() ;)
// DO NOT move this above the 'new' check!
elseif ($value < $current_time)
{
    unset($_SESSION[$key], $_SESSION['__ci_vars'][$key]);
}

Looks like in PHP7 "old" was < time(), whereas in PHP 8 it isn't.  I propose changing this to:

Code:
// Hacky, but 'old' will (implicitly) always be less than time() ;)
// DO NOT move this above the 'new' check!
elseif ($value === 'old' || $value < $current_time)
{
    unset($_SESSION[$key], $_SESSION['__ci_vars'][$key]);
}
Reply


Messages In This Thread
RE: Surprised to see codeigniter 3.x running successfull with PHP 8.0 as well. - by CINewb - 01-14-2021, 04:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB