Topic on Extension talk:Lingo/Flow

Error: Typed property Parser::$mOutput must not be accessed before initialization

9
Summary by Elcapitan68

Proven functionality in the supported environment (Lingo REL1_39 (3.2.0) on MW REL1_39 with a compatible version of PHP).

Extension only guarantees compatibility for LTS MediaWiki versions.

Unluku (talkcontribs)

Hello everyone! I've encountered a bug using VisualEditor with Lingo installed. What happened is it wouldn't let me edit using VisualEditor throwing a following exception:

[exception] [f31f5d51fffaa701908e43c3] /mediawiki/api.php?action=visualeditor&format=json&paction=parse&page=%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0&uselang=en&editintro=&preload=&preloadparams=&formatversion=2   Error: Typed property Parser::$mOutput must not be accessed before initialization
#0 /var/lib/mediawiki/extensions/Lingo/src/LingoParser.php(393): Parser->getOutput()
#1 /var/lib/mediawiki/extensions/Lingo/src/LingoParser.php(77): Lingo\LingoParser->shouldParse()
#2 /var/lib/mediawiki/extensions/Lingo/src/Lingo.php(72): Lingo\LingoParser->parse()
#3 /var/lib/mediawiki/includes/HookContainer/HookContainer.php(161): Lingo\Lingo::Lingo\{closure}()
#4 /var/lib/mediawiki/includes/HookContainer/HookRunner.php(1179): MediaWiki\HookContainer\HookContainer->run()
#5 /var/lib/mediawiki/includes/content/ContentHandler.php(1774): MediaWiki\HookContainer\HookRunner->onContentAlterParserOutput()
#6 /var/lib/mediawiki/includes/content/Renderer/ContentRenderer.php(47): ContentHandler->getParserOutput()
#7 /var/lib/mediawiki/includes/Revision/RenderedRevision.php(259): MediaWiki\Content\Renderer\ContentRenderer->getParserOutput()
#8 /var/lib/mediawiki/includes/Revision/RenderedRevision.php(232): MediaWiki\Revision\RenderedRevision->getSlotParserOutputUncached()
#9 /var/lib/mediawiki/includes/Revision/RevisionRenderer.php(223): MediaWiki\Revision\RenderedRevision->getSlotParserOutput()
#10 /var/lib/mediawiki/includes/Revision/RevisionRenderer.php(164): MediaWiki\Revision\RevisionRenderer->combineSlotOutput()
#11 [internal function]: MediaWiki\Revision\RevisionRenderer->MediaWiki\Revision\{closure}()
#12 /var/lib/mediawiki/includes/Revision/RenderedRevision.php(199): call_user_func()
#13 /var/lib/mediawiki/includes/poolcounter/PoolWorkArticleView.php(84): MediaWiki\Revision\RenderedRevision->getRevisionParserOutput()
#14 /var/lib/mediawiki/includes/poolcounter/PoolWorkArticleViewCurrent.php(104): PoolWorkArticleView->renderRevision()
#15 /var/lib/mediawiki/includes/poolcounter/PoolCounterWork.php(167): PoolWorkArticleViewCurrent->doWork()
#16 /var/lib/mediawiki/includes/page/ParserOutputAccess.php(304): PoolCounterWork->execute()
#17 /var/lib/mediawiki/includes/parser/Parsoid/ParsoidOutputAccess.php(226): MediaWiki\Page\ParserOutputAccess->getParserOutput()
#18 /var/lib/mediawiki/includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php(764): MediaWiki\Parser\Parsoid\ParsoidOutputAccess->getParserOutput()
#19 /var/lib/mediawiki/includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php(577): MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper->getParserOutputInternal()
#20 /var/lib/mediawiki/includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php(438): MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper->getParserOutput()
#21 /var/lib/mediawiki/extensions/VisualEditor/includes/DirectParsoidClient.php(157): MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper->getHtml()
#22 /var/lib/mediawiki/extensions/VisualEditor/includes/ApiParsoidTrait.php(110): MediaWiki\Extension\VisualEditor\DirectParsoidClient->getPageHtml()
#23 /var/lib/mediawiki/extensions/VisualEditor/includes/ApiVisualEditor.php(231): MediaWiki\Extension\VisualEditor\ApiVisualEditor->requestRestbasePageHtml()
#24 /var/lib/mediawiki/includes/api/ApiMain.php(1935): MediaWiki\Extension\VisualEditor\ApiVisualEditor->execute()
#25 /var/lib/mediawiki/includes/api/ApiMain.php(912): ApiMain->executeAction()
#26 /var/lib/mediawiki/includes/api/ApiMain.php(883): ApiMain->executeActionWithErrorHandling()
#27 /var/lib/mediawiki/api.php(95): ApiMain->execute()
#28 /var/lib/mediawiki/api.php(48): wfApiMain()
#29 {main}
‎

I'm running MediaWiki 1.41.1 and Lingo 3.1.1. As a temporal dirty workaround I added some lines in Lingo/src/LingoParser.php that check whether Parser::$mOutput was initialized and it seems to be working:

	/**
	 * @param Parser $parser
	 * @return bool
	 */
	private function shouldParse( $parser ) {
		global $wgexLingoUseNamespaces;

		if ( !( $parser instanceof Parser || $parser instanceof StubObject ) ) {
			return false;
		}

		$reflectionClass = new \ReflectionClass(Parser::class);

		if ( !$reflectionClass->getProperty( 'mOutput' )->isInitialized( $parser ) ) {
			return false;
		}
‎

Is there any solution to this? Thanks in advance!

GobleStL (talkcontribs)
GobleStL (talkcontribs)

Correction - this does not actually fix the issue. It DOES allow VisualEditor to open and work but the the site becomes unstable.

Further investigation revealed that (without the changes) VisualEditor opens up when you are CREATING a new page but pops an error when attempting to edit an existing page.

As a work-around, I simply open a new page and create my changes if needed then switch to Edit Source and copy pasta!

Elcapitan68 (talkcontribs)

I am unsure why do you use Lingo 3.1.1 (this tag was released in 2019).

If you use composer as required https://github.com/wikimedia/mediawiki-extensions-Lingo, it should end up with installing Lingo 3.2.

If you can't use composer for some reason, we suggest installing branch REL1_39 via git. It is targeted at work with MW 1.39 but can work with 1.41, please test.

I updated the direct download link on the extension page so that now it points to the version 3.2.0.

GobleStL (talkcontribs)

Sorry. That is a typo I missed. I am on 3.2.1 and using Composer.

SG

Elcapitan68 (talkcontribs)

I confirm the described behavior in my test environment:

  • MediaWiki 1.41
  • PHP 8.1
  • Lingo 3.2.0

Perhaps it is due to the recent changes in the MediaWiki core.

Lingo with VisualEditor in MediaWiki 1.39

In the recommended environment:

  • MediaWiki 1.39
  • PHP 8.1
  • Lingo 3.2.0

everything works correctly.

Joe Beaudoin Jr. Redux (talkcontribs)

This has not been fixed in MW 1.41 and Lingo 3.2.1. This is still an open issue for REL1_41, which I am able to unfortunately replicate.

Elcapitan68 (talkcontribs)

Thank you for testing. I confirmed the failure for MW 1.41 in the above comment.

As long as the extension compatibility policy is LTS (key: ltsrel), we expect it to work with MW 1.39 and 1.43. Tasks can be added to Phabricator issue tracker about the issues in the non-LTS versions.

Elcapitan68 (talkcontribs)