Page MenuHomePhabricator

Make Wikibase not rely on the ResourceLoader target system
Closed, ResolvedPublic

Description

We'd like to remove the targets system from MediaWiki core. This would lead to less split caches when generating modules; would ensure that all new code gets run on mobile by default and that any code currently not running on mobile gets added leading to improved features.

One issue we ran into while pushing towards this is that Wikibase is making heavy use of the targets system with non-trivial fixes:

  • wikibase.ui.entityViewInit
  • wikibase.ui.entitysearch
  • jquery.wikibase.toolbar.styles,wikibase.common
  • wikibase.client.action.edit.collapsibleFooter
  • wikibase.client.linkitem.init
  • wikibase.client.miscStyles
  • wikibase.lexeme.lexemeview
  • wikibase.lexeme.styles

(Codesearch for those module names)

https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_for_extension_developers#Target_system has some guidance on strategies for migrating this code. Code can still be updated to target only mobile/desktop site if necessary but must make use of a Wikimedia service rather than the targets system.

Options:

  1. Enable everything to target desktop/mobile.
  2. Use Services.
  3. Limit code to relevant skins

Details

Related Changes in Gerrit:
SubjectRepoBranchLines +/-
mediawiki/extensions/Wikibasemaster+1 -82
mediawiki/extensions/Wikibasemaster+4 -4
mediawiki/extensions/Wikibasemaster+4 -5
mediawiki/extensions/Wikibasemaster+0 -10
mediawiki/extensions/Wikibasemaster+35 -51
mediawiki/extensions/Wikibasemaster+0 -2
mediawiki/extensions/Wikibasemaster+0 -2
mediawiki/extensions/Wikibasemaster+0 -28
mediawiki/extensions/Wikibasemaster+75 -31
mediawiki/extensions/Wikibasemaster+21 -11
mediawiki/extensions/Wikibasemaster+0 -24
mediawiki/extensions/Wikibasemaster+30 -0
mediawiki/extensions/Wikibasemaster+94 -96
mediawiki/extensions/WikibaseLexememaster+21 -14
mediawiki/extensions/Wikibasemaster+0 -53
mediawiki/extensions/Wikibasemaster+0 -5
mediawiki/extensions/Wikibasemaster+5 -0
Show related patches Customize query in gerrit

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

@Jdlrobson any patch to help mitigate this and move you forward with your goal is welcome.

Prio Notes:

  • Does not affect end users / production
  • Does not affect development efforts
  • Does not affect onboarding efforts
  • Affects additional stakeholders (WMF web team)

Change 907972 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/Wikibase@master] Drop targets on modules added via BeforePageDisplayMobile hook

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

Change 907973 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/Wikibase@master] Drop targets from library files

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

Change 907974 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/Wikibase@master] Limit modules to pages explicitly rather than relying on targets

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

Change 907996 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/WikibaseLexeme@master] Update targets

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

Change 907997 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/Wikibase@master] Drop targets from library files (1/2)

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

I'm taking a look at this. Out of the above patches https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/907972 should be ready for review.

Change 907972 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Drop targets on modules added via BeforePageDisplayMobile hook

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

@Jdlrobson thanks for the change! Now that this is merged, are there other patches for review for us to prioritize?

Hi, there are 6 patches associated with this ticket. Only one has been reviewed so far (and thanks for that!).

if ( ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) ) {
	$mobileContext = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
	$isMobileView = $mobileContext->shouldDisplayMobileView();
	if ( $isMobileView ) {
	    $out->addModule( 'ext.foo.bar' );
	}
}

One thing that I'm worried about is this approach will create a tight coupling between any extension and MobileFrontend, and if for any reason we need to change MobileFrontend API, then all places that call it would have to be updated. I know it's a common case and plenty of extensions do it this way (https://codesearch.wmcloud.org/search/?q=shouldDisplayMobileView&files=&excludeFiles=&repos=). This is what we currently do but I think if we could improve this. Especially now as it looks like that with removing the target system more and more things will require this check.

I'm wondering whether this should be a responsibility of the OutputPage class or MW Core in general. Therefore I'm thinking about a better approach where communication happens between extensions and MW - not between extensions. MW has a notion of things, but does not implement those - and extensions provide capabilities. To check for the capability - you ask MW Core if it can handle such a scenario (thus you can have multiple extensions providing specific case - for instance, someone could provide their own MobileFrontend implementation).

The mobile view is more a browser/device capability and maybe we could provide some notion of Browser features/capabilities/(naming is hard) and let the OutputPage be aware of context instead of depending on MobileFrontend directly.
Another approach could be providing a Hook but I'm not sure if we want to keep adding hooks.

@Jdlrobson what do you think? Is it something worth pursuing?

I think this approach should be a temporary measure in most if not all cases, and the final solution should be making things work on mobile, or if it’s impossible, making decisions based on the real blocker (if it doesn’t work without a keyboard, check client side if there’s a keyboard available; if it doesn’t work on Minerva, check whether the skin is Minerva etc.), therefore I wouldn’t invest much effort into making this perfect.

The mobile view is more a browser/device capability and maybe we could provide some notion of Browser features/capabilities/(naming is hard) and let the OutputPage be aware of context instead of depending on MobileFrontend directly.

Adding any checks based on browser/device capabilities requires reverse proxy support and increases cache fragmentation. Such a general feature could make people add too many kinds of capability checks.

This is a temporary measure. Per @Tacsipacsi on the long term, decisions should be made based on skin and feature detection. Our goal is to load identical code on mobile / desktop page load and make better decisions around how our features work there.

Hi, there are 6 patches associated with this ticket. Only one has been reviewed so far (and thanks for that!).

Alright, thank you. I've created tasks for us to review the remaining patches that are not WIP, let us know when the last one is also ready.

Change 907997 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Drop targets from library files (1/2)

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

Change 907996 merged by jenkins-bot:

[mediawiki/extensions/WikibaseLexeme@master] Update targets

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

Change 907974 abandoned by Jdlrobson:

[mediawiki/extensions/Wikibase@master] Limit modules to pages explicitly rather than relying on targets

Reason:

FOlded into https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/907973/

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

Change 917382 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/Wikibase@master] Add MobileSite service

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

Change 917382 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Add MobileSite service

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

Change 917854 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/Wikibase@master] Drop RL targets from client (except bridge)

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

Change 917858 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/Wikibase@master] Drop RL targets in repo that are identical to the defaults

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

Change 917859 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/Wikibase@master] Drop RL targets from repo (except experts)

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

Change 917854 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Drop RL targets from client (except bridge)

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

Change 917858 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Drop RL targets in repo that are identical to the defaults

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

Change 918434 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/Wikibase@master] Drop RL targets from repo expert modules

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

Change 918435 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/Wikibase@master] Drop RL target from 'wikibase.ui.entityViewInit'

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

Change 918438 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/Wikibase@master] Drop RL target from wikibase.tainted-ref module

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

Change 917859 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Drop RL targets from repo (except experts)

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

Change 918512 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/Wikibase@master] Drop RL targets from WikiData-Bridge modules

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

Change 918569 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/Wikibase@master] Drop RL targets identical to defaults on module classes

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

Change 918434 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Drop RL targets from repo expert modules

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

Change 918435 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Drop RL target from 'wikibase.ui.entityViewInit'

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

Change 918438 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Drop RL target from wikibase.tainted-ref module

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

Change 918512 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Drop RL targets from Wikidata-Bridge modules

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

Change 918569 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Drop RL targets identical to defaults on module classes

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

Change 919043 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/Wikibase@master] Skip entity search module only on Minerva (and Vector-2022)

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

Change 907973 abandoned by Jdlrobson:

[mediawiki/extensions/Wikibase@master] Limit modules to pages explicitly rather than relying on targets

Reason:

Done in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/919043

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

Change 919043 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Skip entity search module only on Minerva (and Vector-2022)

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

Thank you so much for unblocking this effort! I think this is done now!

Change 922396 had a related patch set uploaded (by Hoo man; author: Hoo man):

[mediawiki/extensions/Wikibase@master] Revert "Restore targets declarations temporarily"

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

Change 922396 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Revert "Restore targets declarations temporarily"

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

Can this be resolved? Looks done to me!

Also caused T340859: Edit buttons overlap on Minerva on Wikidata – gadgets are now causing modules that should be desktop-only to be loaded on mobile as well.

From my point of view yes (T324991#8846440), but I'd defer to @Lucas_Werkmeister_WMDE before closing in case you need to create any follow up tasks.

We already have existing follow-up tasks like T340859 that nobody seems to feel responsible for. (Personally, I don’t see a systematic solution to these issues other than reintroducing the target system, which I maintain was useful and should not have been removed, but I doubt that’s going to happen.) So I guess we can close this.

ItamarWMDE claimed this task.

Okay, so I'll close this then, as the issues exhibited in T340859 are actually the issues we want to address with T343052: Evaluate Wikidata's mobile site: Reconsider how Wikidata uses MobileFrontend/Minerva which is currently under the consideration of product. Thank you for your input!

For quite some time now, a JavaScript error has been occurring on Commons. See T321532 for details.

Since this ticket was created after T321532, it therefore should not be the direct cause of the error, but there appears to be a connection between them.

there appears to be a connection between them.

More specifically? As the author of one of the duplicates of T321532, I’d love it to be fixed, but I fail to see the connection between the two tasks.