Page MenuHomePhabricator

Migrate legacy redirectToFragment to modern structure
Closed, ResolvedPublic

Description

If a redirect points to a page with an anchor, an inline script is added to the page, which calls redirectToFragment() from wikibits.js.

As there is now the possibility to turn off loading of wikibits.js via $wgIncludeLegacyJavaScript, the inline script should be replaced with something more modern.

Possible fix: Add a mw.config variable like wgRedirectFragment to the page and put the functionality of redirectToFragment() into mediawiki.page.startup.


Version: 1.18.x
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=51736

Details

Reference
bz35858

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 12:11 AM
bzimport set Reference to bz35858.

This also breaks on mobile where legacy code is not loaded.

(In reply to comment #0)

Possible fix: Add a mw.config variable like wgRedirectFragment to the page
and put the functionality of redirectToFragment() into mediawiki.page.startup.

Sounds good, though maybe in mediawiki.page.ready or mediawiki.util instead.

Things we can clean up:

  • Expose fragment target through mw.config (instead of direct invocation by extra inserted <script> element)
  • Avoid creating extra history entries (probably by using location.replace instead of location.hash = '').
  • Move interface from legacy.wikibits to mediawiki.util or mediawiki.page.ready (either way exposed as a public method as it seems generally useful to be able to call from code, especially considering the prep work in mw.hook that encourages this model where we don't make things exclusively available for the default page load).

As the Target Milestone on this ticket has been set to 1.22.0:

According to http://lists.wikimedia.org/pipermail/wikitech-l/2013-September/072030.html "MediaWiki 1.22 is slated for release on November 30th, at the very latest."

If this is still intended to get fixed for 1.22.0, a patch is needed soon.

Change 94412 had a related patch set uploaded by Umherirrender:
migrate redirectToFragment() from wikibits.js to own module

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

[Bumping TM as MediaWiki 1.22.0 tarball was released today.]

Change 94412 merged by jenkins-bot:
Migrate redirectToFragment() from wikibits.js to own module

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

Change 132181 had a related patch set uploaded by MarkAHershberger:
Migrate redirectToFragment() from wikibits.js to own module

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

cherry pick failed, but if someone wants to take this on, we could merge it.

Current patch is -2 due to Jenkins bot; reclosing as FIXED (for 1.23/master).

Change 132181 abandoned by Bartosz Dziewoński:
Migrate redirectToFragment() from wikibits.js to own module

Reason:
I'm going to declare that this is not a critical bugfix and thus is not worth the hassle to backport.

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

Remove backport flag due to abandon reason.