Skip to content
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

Fix support for mediawiki 1.35 #14

Open
paladox opened this issue Oct 16, 2020 · 0 comments
Open

Fix support for mediawiki 1.35 #14

paladox opened this issue Oct 16, 2020 · 0 comments

Comments

@paladox
Copy link

paladox commented Oct 16, 2020

ErrorException from line 99 of /srv/mediawiki/w/extensions/CrossReference/CrossReference.php: PHP Warning: Parameter 2 to ExtCrossReference::parserAfterTidy() expected to be a reference, value given
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/w/extensions/CrossReference/CrossReference.php(99): call_user_func_array(array, array)
#2 /srv/mediawiki/w/includes/HookContainer/HookContainer.php(320): CrossReference_HookStub->__call(string, array)
#3 /srv/mediawiki/w/includes/HookContainer/HookContainer.php(131): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array)
#4 /srv/mediawiki/w/includes/HookContainer/HookRunner.php(2894): MediaWiki\HookContainer\HookContainer->run(string, array)
#5 /srv/mediawiki/w/includes/parser/Parser.php(1693): MediaWiki\HookContainer\HookRunner->onParserAfterTidy(Parser, string)
#6 /srv/mediawiki/w/includes/parser/Parser.php(654): Parser->internalParseHalfParsed(string, boolean, boolean)
#7 /srv/mediawiki/w/includes/cache/MessageCache.php(1301): Parser->parse(string, Title, ParserOptions, boolean)
#8 /srv/mediawiki/w/includes/language/Message.php(1258): MessageCache->parse(string, Title, boolean, boolean, LanguageEn)
#9 /srv/mediawiki/w/includes/language/Message.php(889): Message->parseText(string)
#10 /srv/mediawiki/w/includes/language/Message.php(942): Message->toString(string)
#11 /srv/mediawiki/w/skins/Timeless/includes/TimelessTemplate.php(233): Message->parse()
#12 /srv/mediawiki/w/skins/Timeless/includes/TimelessTemplate.php(984): TimelessTemplate->getPortlet(string, array, string)
#13 /srv/mediawiki/w/skins/Timeless/includes/TimelessTemplate.php(90): TimelessTemplate->getInterwikiLinks()
#14 /srv/mediawiki/w/includes/skins/SkinTemplate.php(129): TimelessTemplate->execute()
#15 /srv/mediawiki/w/includes/skins/SkinTemplate.php(144): SkinTemplate->generateHTML()
#16 /srv/mediawiki/w/includes/OutputPage.php(2615): SkinTemplate->outputPage()
#17 /srv/mediawiki/w/includes/MediaWiki.php(947): OutputPage->output(boolean)
#18 /srv/mediawiki/w/includes/MediaWiki.php(960): MediaWiki->{closure}()
#19 /srv/mediawiki/w/includes/MediaWiki.php(543): MediaWiki->main()
#20 /srv/mediawiki/w/index.php(53): MediaWiki->run()
#21 /srv/mediawiki/w/index.php(46): wfIndexMain()
#22 {main}
qx1147 added a commit to qx1147/mediawiki-crossreference that referenced this issue Sep 9, 2022
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant