Last modified: 2014-09-21 00:25:32 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T37045, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 35045 - Use history.replaceState to rewrite redirect urls
Use history.replaceState to rewrite redirect urls
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Redirects (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: 1.24.0 release
Assigned To: Bartosz Dziewoński
:
: 48028 (view as bug list)
Depends on:
Blocks: 70962 39328 67330
  Show dependency treegraph
 
Reported: 2012-03-07 23:00 UTC by Daniel Friesen
Modified: 2014-09-21 00:25 UTC (History)
12 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Daniel Friesen 2012-03-07 23:00:46 UTC
Modern browsers include a history api including pushState/popState/replaceState support. Using these apis one can dynamically alter the path portion of the address in the address bar without leaving the page. Additionally if you use replaceState you don't create side effects in forward/back history.

Using this api it's possible to make [[Wikipedia:Redirection]]'s /wiki/Redirection dynamically change to /wiki/Redirect in the user's browser.

I've been experimenting with a script to do that:
https://en.wikipedia.org/wiki/User:Dantman/vector.js

We should consider fine tuning code to do this and including it in core.

From the user perspective this would have a similar effect to using 301s. It would make end users end up copying the canonical url instead of the redirect's url.
Comment 1 Bartosz Dziewoński 2014-07-03 10:12:06 UTC
Well, it's about time we did this already.
Comment 2 Gerrit Notification Bot 2014-07-03 10:29:33 UTC
Change 143852 had a related patch set uploaded by Bartosz Dziewoński:
On redirect, actually rewrite page URL to the target one with JavaScript

https://gerrit.wikimedia.org/r/143852
Comment 3 Krinkle 2014-07-03 13:25:00 UTC
*** Bug 48028 has been marked as a duplicate of this bug. ***
Comment 4 Gerrit Notification Bot 2014-08-20 20:30:42 UTC
Change 143852 merged by jenkins-bot:
On redirects update the URL to that of the target page with JavaScript

https://gerrit.wikimedia.org/r/143852
Comment 5 Bartosz Dziewoński 2014-08-20 21:27:17 UTC
Yay!
Comment 6 Derk-Jan Hartman 2014-08-29 11:40:03 UTC
Seems that replaceState on IE10 is not scrolling to the anchor position.
Comment 7 Bartosz Dziewoński 2014-08-29 14:08:58 UTC
Filed as bug 70176, I'll look into it.
Comment 8 MZMcBride 2014-08-31 16:50:24 UTC
This is awesome. Thank you, Bartosz!
Comment 9 Ricordisamoa 2014-09-01 23:37:49 UTC
Just wondering, why not to use a server-side redirect?
Comment 10 Bartosz Dziewoński 2014-09-01 23:51:17 UTC
That's been discussed on bug 18883: we wouldn't be able to display the "Redirected from" message.

We also probably wouldn't be able to support redirects to sections if we did that (but I don't think anybody has done cross-browser testing) and it would probably require additional work on the ops side of things (but I don't think anybody has looked into this either). The "Redirected from" is the primary reason.
Comment 11 Ricordisamoa 2014-09-02 03:27:51 UTC
Now MediaWiki behaves very differently with JavaScript disabled.
Why wouldn't the "Redirected from" message work with a server-side solution?
Comment 12 Ricordisamoa 2014-09-02 03:34:22 UTC
To be clear, I don't oppose the change per se, in fact I even wrote a JS hack for it: [[m:User:Ricordisamoa/SkipRedirect.js]]
Comment 13 jeremyb 2014-09-02 04:06:55 UTC
(In reply to Ricordisamoa from comment #11)
> Now MediaWiki behaves very differently with JavaScript disabled.

Yes

> Why wouldn't the "Redirected from" message work with a server-side solution?

So, if you did it server-side, where would you redirect to? Not just the canonical path because then how does the server detect that the followup needs to show the redirected from msg? and if you create a new style of URL (e.g. ${canonical}?rdfrom=origtitle) to redirect to then we have extra complexity and it's still not landing at the canonical URL. unless we did both ?rdfrom and also pushstate to remove the rdfrom param. but that's no better than what's deployed now.
Comment 14 Ricordisamoa 2014-09-02 04:20:59 UTC
(In reply to jeremyb from comment #13)
> how does the server detect that the followup needs to show the redirected from msg?

Would it be possible to pass a 'rdfrom' POST parameter to the target page?
Comment 15 jeremyb 2014-09-02 04:23:55 UTC
(In reply to Ricordisamoa from comment #14)
> (In reply to jeremyb from comment #13)
> > how does the server detect that the followup needs to show the redirected from msg?
> 
> Would it be possible to pass a 'rdfrom' POST parameter to the target page?

No. And even if possible client side (which it's not) we wouldn't anyway because of implications for varnish.
Comment 16 Benjamin Mako Hill 2014-09-20 00:41:13 UTC
I've a researcher who has studied redirects in Wikipedia. I'm also active from time to time on https://en.wikipedia.org/wiki/Wikipedia:Redirects_for_discussion where we very frequently use viewership statistics to make decisions on which redirects to keep.  I wanted to confirm that I understand the effect of this patch on that data that Wikimedia publishes.

Here's my understanding:

To date, views to redirects count as a views to the redirect page from the perspective of our view-tracking software (e.g., on http://stats.grok.se/). This patch will make it appear, from the browser's URL bar and browser history, that the user is visiting the target page. This patch will not change the way that views are recorded in our view log tables. Things will continue to be recorded in the view logs published by WMF just as they have before.

If, however, we were to use any data stored by a users personal history file stored in their browser, the fact that users visited a redirect (and not the target page directly) would disappear.

Is that all correct?
Comment 17 MZMcBride 2014-09-20 01:09:10 UTC
(In reply to jeremyb from comment #13)
> (In reply to Ricordisamoa from comment #11)
>> Now MediaWiki behaves very differently with JavaScript disabled.
> 
> Yes

Can someone please elaborate on the "very different" behavior here? Specifics would help.


(In reply to Benjamin Mako Hill from comment #16)

I believe your understanding is correct, yes.

P.S. Hi! Nice to see you active here. :-)
Comment 18 Matthias Becker 2014-09-20 22:56:40 UTC
I consider resolving this bug IS a bug. For people who work with redirects, as for example fixing them, moving pages and so on, after looking into another page like the version history or the talk page you can't go back by hitting the left arrow in your browser that is pretty annoying, especially i you forgot to note the name of the redirect you came through – you simply have no possibility to find again the redirect easily, if so.

Also, if I understand comment # 16 correctly it became impossible to distinguish how many users came through which redirect and therefore the possibility is lost to determine which redirects are useful and which are not or if the construct of a disambiguation page should be modified or not.

This should be reverted to the former behaviour.
Comment 19 Daniel Friesen 2014-09-21 00:25:32 UTC
(In reply to Matthias Becker from comment #18)
> I consider resolving this bug IS a bug. For people who work with redirects,
> as for example fixing them, moving pages and so on, after looking into
> another page like the version history or the talk page you can't go back by
> hitting the left arrow in your browser that is pretty annoying, especially i
> you forgot to note the name of the redirect you came through – you simply
> have no possibility to find again the redirect easily, if so.

When you land on a redirect the "Redirected from" is still there. And (at least as far as testing in Firefox goes) when I land on a redirect, go to history, then press back the page I go back to still has the "Redirected from" line there.

The UI/workflow for people working with redirects is still there.

> Also, if I understand comment # 16 correctly it became impossible to
> distinguish how many users came through which redirect and therefore the
> possibility is lost to determine which redirects are useful and which are
> not or if the construct of a disambiguation page should be modified or not.

No, the address bar change is done by JS after load. The HTTP request for redirect pages is still the same URL and logs can still distinguish when a user lands on the canonical page or the redirect.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links