Page MenuHomePhabricator

ResourceLoaderWikiModule should follow redirects for JavaScript/CSS content
Closed, ResolvedPublic

Description

For the migration to Gadgets 2.0 we need to be able to rename JavaScript and CSS pages without compromising the integrity of module loading. The raw redirect content for JavaScript pages is a mw.loader.load() for the action=raw url, however such request is asynchronous so the module would be ready (and dependants fired) before the actual scripts have been loaded.

Prevent that by making the WikiModule class resolve redirects.

Event Timeline

Krinkle created this task.Aug 11 2015, 12:59 AM
Krinkle raised the priority of this task from to Needs Triage.
Krinkle updated the task description. (Show Details)
Krinkle added subscribers: Krinkle, Legoktm, Krenair.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 11 2015, 12:59 AM
He7d3r added a subscriber: He7d3r.Aug 11 2015, 2:02 PM
Krinkle triaged this task as Medium priority.Aug 28 2015, 10:28 AM
Krinkle set Security to None.
Krinkle moved this task from Inbox to Accepted Enhancement on the MediaWiki-ResourceLoader board.
Krinkle raised the priority of this task from Medium to High.Dec 16 2015, 8:33 PM
Krinkle added a project: Gadgets-2.0.
kaldari added a subscriber: kaldari.Feb 2 2016, 9:39 PM

Gadgets 2.0 is almost ready to go. Is anyone planning on taking this bug or should I move it to the Community-Tech workboard?

@Krinkle: Where would be the best place to implement the redirect resolving? ResourceLoaderWikiModule::getContent()?

Krinkle added a comment.EditedFeb 9 2016, 8:14 PM

@Krinkle: Where would be the best place to implement the redirect resolving? ResourceLoaderWikiModule::getContent()?

I think so, yes. See MediaWiki.php at https://github.com/wikimedia/mediawiki/blob/d70e36235328c6bd3ddddd0528c94addca4a961a/includes/MediaWiki.php#L429-L440 for similar code.

Untested, but the following should work: WikiPage::factory( Title ), isRedirect(), followRedirect(). Then with the returned Title continue on Revision::newFromTitle in ResourceLoaderWikiModule::getContent() as currently the case. Be sure to guard against non-Title return values (such as strings and booleans) as those external interewiki and specialpage titles, which aren't valid as module content.

kaldari added a comment.EditedFeb 11 2016, 4:42 AM

@Krinkle: After this bug is solved, will we also need to update the code that creates redirects for JavaScript pages, or is WikiPage::followRedirect() smart enough to deal with that already?

Change 269901 had a related patch set uploaded (by Kaldari):
Make WikiModule class follow redirects for JavaScript/CSS content

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

@Krinkle: After this bug is solved, will we also need to update the code that creates redirects for JavaScript pages.

When ad9f14d6 added support for redirects to JavaScript pages, it naturally made WikiPage methods for redirect chains etc. work as expected too. Shouldn't need any changing.

kaldari moved this task from New & TBD Tickets to Bug backlog on the Community-Tech board.
Krinkle renamed this task from WikiModule class should follow redirects for JavaScript/CSS content to ResourceLoaderWikiModule should follow redirects for JavaScript/CSS content.Mar 15 2017, 4:06 AM
Krinkle claimed this task.
Krinkle moved this task from Bug backlog to Older: Team Work on the Community-Tech board.
Krinkle moved this task from Accepted Enhancement to Assigned on the MediaWiki-ResourceLoader board.
Krinkle added a project: Performance-Team.
Krinkle moved this task from Inbox to Radar on the Performance-Team board.
Krinkle added a subscriber: Catrope.

Change 269901 merged by jenkins-bot:
[mediawiki/core] resourceloader: Follow redirects for JavaScript/CSS in WikiModule

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

Krinkle closed this task as Resolved.Mar 22 2017, 4:00 AM