from /srv/mediawiki/1.42/includes/gallery/TraditionalImageGallery.php(71)<br />\n#0 /srv/mediawiki/1.42/extensions/Cargo/includes/formats/CargoGalleryFormat.php(170): TraditionalImageGallery->toHTML()
Description
Details
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Fix "Error: Call to a member function addModules() on null" | mediawiki/extensions/Cargo | master | +8 -1 |
Event Timeline
Change #1078053 had a related patch set uploaded (by Paladox; author: Paladox):
[mediawiki/extensions/Cargo@master] Fix "Error: Call to a member function addModules() on null"
Hi - what version of Cargo? For what it's worth, the current/old code works fine me, on MW 1.43.
Okay. That's unfortunate - I just tried, and it it looks like, with MW 1.43, the exact opposite problem happens: getParser() works fine, but using getParserFactory() leads to that "Call to a member function addModules() on null" error. Evidently there was some rearrangement of the setting of ParserOutput between MW 1.42 and 1.43. I don't know what the best solution for this is.
Actually - having looked more at the code, I may have found a fix that works for all MW versions. Could you try putting in the following change?
--- a/includes/formats/CargoGalleryFormat.php +++ b/includes/formats/CargoGalleryFormat.php @@ -142,7 +142,12 @@ class CargoGalleryFormat extends CargoDisplayFormat { // User specified something invalid, fallback to default. $gallery = ImageGalleryBase::factory( false ); } - $gallery->setParser( MediaWikiServices::getInstance()->getParser() ); + $parseWidthParamChecker = new ReflectionMethod( Parser::class, 'parseWidthParam' ); + if ( !$parseWidthParamChecker->isStatic() ) { + // MW >= 1.43 + // This is all due to the change at + // https://phabricator.wikimedia.org/rMW0450b5e4d58387a0d57dc699c2c58f8e780ca44e + $gallery->setParser( MediaWikiServices::getInstance()->getParser() ); + }
Change #1078053 merged by jenkins-bot:
[mediawiki/extensions/Cargo@master] Fix "Error: Call to a member function addModules() on null"