Page MenuHomePhabricator

Hook Cite::checkRefsNoReferences has invalid call signature;
Closed, ResolvedPublic

Description

When I try to access the specialpage FormulaInfo I get the following error

Detected bug in an extension! Hook Cite::checkRefsNoReferences has invalid call signature; Parameter 2 to Cite::checkRefsNoReferences() expected to be a reference, value given

Backtrace:

#0 /srv/vagrant/mediawiki/extensions/Math/MathTexvc.php(410): Hooks::run(string, array)
#1 /srv/vagrant/mediawiki/extensions/MathSearch/FormulaInfo.php(205): MathTexvc->getPng()
#2 /srv/vagrant/mediawiki/extensions/MathSearch/FormulaInfo.php(98): FormulaInfo->DisplayRendering(string, integer)
#3 /srv/vagrant/mediawiki/extensions/MathSearch/FormulaInfo.php(37): FormulaInfo->DisplayInfo(string, string)
#4 /srv/vagrant/mediawiki/includes/specialpage/SpecialPage.php(384): FormulaInfo->execute(NULL)
#5 /srv/vagrant/mediawiki/includes/specialpage/SpecialPageFactory.php(553): SpecialPage->run(NULL)
#6 /srv/vagrant/mediawiki/includes/MediaWiki.php(249): SpecialPageFactory::executePath(Title, RequestContext)
#7 /srv/vagrant/mediawiki/includes/MediaWiki.php(678): MediaWiki->performRequest()
#8 /srv/vagrant/mediawiki/includes/MediaWiki.php(475): MediaWiki->main()
#9 /srv/vagrant/mediawiki/index.php(41): MediaWiki->run()
#10 /var/www/w/index.php(5): include(string)
#11 {main}

Event Timeline

Physikerwelt updated the task description. (Show Details)
Physikerwelt raised the priority of this task from to Needs Triage.
Physikerwelt added projects: Cite, MathSearch.
Physikerwelt added a subscriber: Physikerwelt.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 11 2015, 3:14 PM
Physikerwelt added a comment.EditedJul 11 2015, 3:15 PM

Disabling the cite extension resolves the problem.

Physikerwelt set Security to None.Jul 11 2015, 3:16 PM
Physikerwelt added a subscriber: Hcohl.
Physikerwelt added a subscriber: matmarex.

The problem is actually with the Math extension, which calls the ParserAfterParse hook for some reason (I refuse to investigate what for, it looks like a horrible hack) with different signature than core does it.

class MathTexvc extends MathRenderer {
	...
	public function getPng() {
		global $wgHooks;
		// Workaround for bugfix for Bug 56769
		if ( !isset( $wgHooks['ParserAfterParse']['FlushMathBackend'] ) ) {
			// saves the PNG-file
			Hooks::run( 'ParserAfterParse', array( new Parser(), '', new StripState( '' ) ) );
		}
		$backend = $this->getBackend();
		return $backend->getFileContents( array( 'src' => $this->getHashPath() . "/" . $this->getHash() . '.png' ) );
	}
}

While core does:

Hooks::run( 'ParserAfterParse', array( &$this, &$text, &$this->mStripState ) );

Cite depends on the parameters being passed as references:

class Cite {
	...
	function checkRefsNoReferences( $afterParse, &$parser, &$text ) {
		...

The Parser and StripState parameters probably don't really need to be passed as references for the hook to work correctly (I guess this dates back to PHP 4's half-baked objects), but text does.

Change 226292 had a related patch set uploaded (by Bartosz Dziewoński):
Unbreak some weird terrible ParserAfterParse hook hack

https://gerrit.wikimedia.org/r/226292

@matmarex Thank you very much for looking into this. This workaround is really one of the ugliest things at all. Another a reason to get rid of the PNG images (T74240).

The patch is definetly a step forward. But the problem is not solved.

Exception encountered, of type "BadMethodCallException"
[9df80002] /w/index.php?title=Special:FormulaInfo&pid=44539&eid=DLMF%3A25.11%3AE1 BadMethodCallException from line 1061 of /srv/vagrant/mediawiki/extensions/Cite/Cite_body.php: Call to a member function checkRefsNoReferences() on a non-object (NULL)
Backtrace:
#0 /srv/vagrant/mediawiki/includes/Hooks.php(204): Cite->checkRefsNoReferences(boolean, Parser, string)
#1 /srv/vagrant/mediawiki/extensions/Math/MathTexvc.php(413): Hooks::run(string, array)
#2 /srv/vagrant/mediawiki/extensions/MathSearch/FormulaInfo.php(205): MathTexvc->getPng()
#3 /srv/vagrant/mediawiki/extensions/MathSearch/FormulaInfo.php(98): FormulaInfo->DisplayRendering(string, integer)
#4 /srv/vagrant/mediawiki/extensions/MathSearch/FormulaInfo.php(37): FormulaInfo->DisplayInfo(string, string)
#5 /srv/vagrant/mediawiki/includes/specialpage/SpecialPage.php(384): FormulaInfo->execute(NULL)
#6 /srv/vagrant/mediawiki/includes/specialpage/SpecialPageFactory.php(553): SpecialPage->run(NULL)
#7 /srv/vagrant/mediawiki/includes/MediaWiki.php(249): SpecialPageFactory::executePath(Title, RequestContext)
#8 /srv/vagrant/mediawiki/includes/MediaWiki.php(677): MediaWiki->performRequest()
#9 /srv/vagrant/mediawiki/includes/MediaWiki.php(474): MediaWiki->main()
#10 /srv/vagrant/mediawiki/index.php(41): MediaWiki->run()
#11 /var/www/w/index.php(5): include(string)
#12 {main}

Change 226304 had a related patch set uploaded (by Bartosz Dziewoński):
Ignore parsers without extCite

https://gerrit.wikimedia.org/r/226304

Jdforrester-WMF closed this task as Resolved.Jul 22 2015, 4:24 PM
Jdforrester-WMF claimed this task.

Change 226292 merged by jenkins-bot:
Pass arguments to ParserAfterParse by reference

https://gerrit.wikimedia.org/r/226292

Change 226304 merged by jenkins-bot:
Ignore parsers without extCite

https://gerrit.wikimedia.org/r/226304