PHP 5.3.0 Pass by reference extension hook bug |
|||
|---|---|---|---|
| Date: | 01/06/2010 | Show-stopper?: | |
| Status: | Bug Squashed | Reporter: | Leevi Graham |
| Reported in Version: | EE 1.6.8 | Assigned To: | Derek Jones |
| Keywords: | PHP Errors, | ||
| Support Thread: | |||
Details
Hey guys,
Some thing curious is happening with PHP 5.3 and the hook system. I can’t quite figure it out for sure but here’s how to replicate the issue:
Using the latest build of EE and PHP 5.3.0:
- Create two extensions that use sessions_end in the CP (LG Addon Updater is one) but at different priority
- Both hook methods should accept the session param by reference: sessions_start(&s)
- The lower priority extension throws an error
This is a pretty big issue because it breaks all third party extension that use sessions_start and sessions_end.
The error: Warning: Parameter 1 to my_class::sessions_start() expected to be a reference, value given in /Users/leevigraham/Sites/Internal/local.expressionengine/www/ee-admin/core/core.extensions.php on line 278
Cheers
Comment on Bug Report
| Posted by: Robin Sowell on 7 January 2010 9:59am | |
|
|
[ Permalink ]
Blast- that should be addressed, but given my lack of running 5.3 I’m going to see if Greg can reproduce. |
| Posted by: Derek Jones on 7 January 2010 12:35pm | |
|
|
[ Permalink ]
Confirmed, looking into it, thanks Leevi. |
| Posted by: Derek Jones on 7 January 2010 1:01pm | |
|
|
[ Permalink ]
Ok, found the problem, and 5.3 is giving me a headache. On line 179 you can see that we are properly converting the $args captured by func_get_args() to a reference instead of a variable, but for some reason within the foreach() loop below, after $args is accessed the first time on line 278 it is becoming a value again. To get around this for now, you can move that loop on line 179 inside the foreach on line 193. I’m going to look a bit more closely including going to the PHP source code to see why this is happening before settling on that for a final solution, though, as it does not sit well with me. |
| Posted by: Derek Jones on 8 January 2010 1:21pm | |
|
|
[ Permalink ]
I’ve made a more acceptable change, Leevi. I’ll send you the files so you can continue working. |
| Posted by: Leevi Graham on 17 January 2010 10:47pm | |
|
|
[ Permalink ]
Thanks guys. The files you sent fixed this issue. |
