-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hooks passing by ref #54
Comments
Yes, that's true. What I proposed a while ago (don't remember where), was something intermediated: all the new hooks remove the ampersand, for the old ones keep it for a bit of compatibility. Though I don't have big problems with one or the other solution... |
It's deprecated in PHP 5.3 as well. |
Yes, but does not give a w warning if passed through call_user_func_array(). |
What I am getting at is that we should be logging that as a bug and changing the hooks before we release 2.1. |
I totally agree! In fact, that is precisely the reason I opened this issue. Now, to get the dev heads to agree.... |
I think we should definitely change this for 2.1, and also post something on SMF alerting mod authors to this issue so they can fix their code. I ran into this issue with my SMF+G2 mod when I upgraded to PHP 5.4 a while back, and I'm sure others will as well (though I haven't seen any support posts relating to that issue on the support forum for that mod). |
…, while hooks already present in 2.0 will still pass by-ref [Issue SimpleMachines#54] Signed-off-by: emanuele <emanuele45@gmail.com>
@emanuele45 , does that commit make this closed? |
Not so sure...it's a step. |
Num: #209 doesn't change pass by ref. What is the idea right now, pass by value for new hooks only? |
I believe the current state is that all new hooks added in 2.1 only pass by value so they are 5.4 compliant. There is still discussion if we want to make a breaking commit and change the ones that were in place at 2.0. At some point those will have to be changed regardless so seems like a better to do sooner than later ... IMO of course |
I agree at this point. The changes will need documented, preferably both on the development wiki as well as a blog dedicated to hooks in 2.1. Explanation, use example(s). |
…any more, while hooks already present in 2.0 will still pass by-ref [Issue SimpleMachines#54]" This reverts commit 99797a9. Conflicts: Sources/Load.php Sources/ManageLanguages.php Sources/ManageSearch.php
How many integration hooks are still called by reference like this? PHP 5.3 is essentially EOL now (5.3.27 is the last release in that line apparently) and PHP 5.5.0 went gold last month, so we should start planning to make SMF compatible with 5.5. |
The point of this error is not the call-by-ref, the error in all the hooks that were throwing that error was that the parameters were not in an array: And with the latest revert I did 5 months ago SMF 2.1 should already compatible with php 5.4 and 5.5. |
Thanks for the insight. I'll go through the hooks in the coming days and fix any remaining issues along those lines. I haven't tested PHP 5.5 at all, so I don't know what, if anything, needs to be done for that. |
Does anything else need to be done with this? (Fairly sure, incidentally, that the values inside the arrays actually have to be references if the receiving function is also expecting references. This might mean we should be checking what we want to make available and check that things are so. Perhaps we need a test suite for all hooks to validate that sensible values are provided for each hook.) |
I never got around to fixing the remaining hooks apparently, so that still needs to be done. |
What does? I looked through the hooks quickly, I couldn't find any hooks that weren't passing their exported values with arrays as they're supposed to... |
OK, I'm going to mark this closed because I'm not sure what actually needs to be done. If there are any problems with any existing hooks, we'll deal with them as we find them for now. |
Before PHP 5.4, referenced variables were passed to the function by reference, regardless of whether the function expects the respective parameter to be passed by reference. This form of call-time pass by reference did not emit a deprecation notice, even though it was deprecated, and has been removed in PHP 5.4.
So I suggest all variables passed through call_integration_hook are done by value. Removing the ampersand in front of the var.
Lastly, I'll note that some poorly written plugins will break. But they already break in 5.4, so this argument is invalid.
The text was updated successfully, but these errors were encountered: