Fix call-by-reference issue introduced with PHP 5.4.0#15
Open
qx1147 wants to merge 1 commit intostaspika:masterfrom
Open
Fix call-by-reference issue introduced with PHP 5.4.0#15qx1147 wants to merge 1 commit intostaspika:masterfrom
qx1147 wants to merge 1 commit intostaspika:masterfrom
Conversation
This fixes the issue staspika#14, i.e., the warning "Parameter 1 to ExtCrossReference::parserAfterTidy() expected to be a reference [...]" and the extension not correctly inserting the cross-references into the page. This issue is actually caused by PHP which handles things around passing function variables differently since PHP 5.4.0 (see also https://www.php.net/releases/5_4_0.php regarding allow_call_time_pass_reference, and https://wiki.php.net/rfc/calltimebyref). Regarding the code change: The "parserAfterTidy" callback, which is the only callback used by the CrossReference extension that requires a call-by-reference variable in order to return modified text, was handled by the __call() method (which, in turn is called through the PHP function call_user_func_array()). This is what was not working anymore and is fixed by implementing the "parserAfterTidy" callback function explicitly and with the correct function parameter declarations for passing on a reference rather than a value. The fix should be back-compatible with older PHP versions, but I verified it with PHP 7.4.30 (and MediaWiki 1.35.7).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the issue #14, i.e., the warning "Parameter 1 to ExtCrossReference::parserAfterTidy() expected to be a reference [...]" and the extension not correctly inserting the cross-references into the page. This issue is actually caused by PHP which handles things around passing function variables differently since PHP 5.4.0 (see also https://www.php.net/releases/5_4_0.php regarding allow_call_time_pass_reference, and https://wiki.php.net/rfc/calltimebyref). Regarding the code change: The "parserAfterTidy" callback, which is the only callback used by the CrossReference extension that requires a call-by-reference variable in order to return modified text, was handled by the __call() method (which, in turn is called through the PHP function call_user_func_array()). This is what was not working anymore and is fixed by implementing the "parserAfterTidy" callback function explicitly and with the correct function parameter declarations for passing on a reference rather than a value. The fix should be back-compatible with older PHP versions, but I verified it with PHP 7.4.30 (and MediaWiki 1.35.7).