Page MenuHomePhabricator

Replace $wgMFUseParsoid configuration flag with Parsoid API
Closed, ResolvedPublic2 Estimated Story Points

Description

Background

The web team is working on migrating MobileFrontend to Parsoid. While working on this we were unable to find a reliable way to detect whether Parsoid was enable. This logic seems to exist in ParserMigration extension but doesn't seem to be formalized in an API. We tried using ParserOptions::getUseParsoid() but we get different results relating to race conditions relating to order dependencies so need something more reliable.

Currently, we are using a placeholder config flag (MFUseParsoid) to condition whether to turn on section collapsing for mobile when using parsoid. Now that we have the ParserMigration.Oracle service, this is no longer necessary as we can query whether parsoid will be used or not

User story

As a developer in the ArticleParserOptions hook I need to be able to call a function that returns a boolean to tell me whether Parsoid read views is enabled or not.

public function onArticleParserOptions( Article $article, ParserOptions $parserOptions )

Requirements

  • It should be possible to do this check in the hook in cases where the hook runs before the equivalent hook in ParserMigration.
  • If the parameters under which the parser is loaded change, callers (e.g. MobileFrontend) should not need to change anything.

Acceptance criteria (Mobilefrontend)

  • Remove $wgMFUseParsoid in favor of the new Oracle service

This task was created by Version 1.0.0 of the [[ mediawiki.org/w/index.php?title=Reading/Web/Request_process | Web team task template ]]

Event Timeline

Change #1027017 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/extensions/ParserMigration@master] Factor out ParserMigration.Oracle service

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

Change #1027017 merged by jenkins-bot:

[mediawiki/extensions/ParserMigration@master] Factor out ParserMigration.Oracle service

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

Thanks for the new API! Steph will take a look at this and check it meets our requirements in time for estimation Thursday.

Added a bit of context - this ticket is ready to estimate on Thursday!

MSantos subscribed.

Please let us know if there are anything actionable on Content-Transform-Team to support you.

Thanks we will take this task from here and let you know if we run into any issues on MobileFrontend side.
A quick glance suggests this is working as expected.

		// set the collapsible sections parser flag so that section content is wrapped in a div for easier targeting
		// only if we're in mobile view and the config flag is set
		$useParsoid = MediaWikiServices::getInstance()->get( 'ParserMigration.Oracle' )
			->shouldUseParsoid( $context->getUser(), $context->getRequest(), $article->getTitle() );

		if ( $context->shouldDisplayMobileView() && $useParsoid ) {
			$parserOptions->setCollapsibleSections();
		}
ovasileva set the point value for this task to 2.Thu, May 16, 5:50 PM

Change #1034152 had a related patch set uploaded (by Stoyofuku-wmf; author: Stoyofuku-wmf):

[mediawiki/extensions/MobileFrontend@master] Remove MFUseParsoid, use ParserMigration Oracle service

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

Patch affected by T365403, will pick up again when I can

Change #1034152 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] Remove MFUseParsoid, use ParserMigration Oracle service

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

SToyofuku-WMF subscribed.

@Jdlrobson do you want to do QA for this as well, or should I write steps in the ticket?

@Jdlrobson wanted to double check if Edward should be the one to QA this or if you wanted to - I realize you might want to do sign off, in which case I'm happy to add QA steps

Jdlrobson added a project: Verified.

No need for QA on this one. I can verify this is working as expected on office.wikimedia.org