r44981 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44980‎ | r44981 | r44982 >
Date:21:57, 23 December 2008
Author:brion
Status:ok (Comments)
Tags:
Comment:
Pull back r44972 for now "(Bug 16677) Media: view URLs should HTTP-redirect to canonical File: namespace"

r44972 isn't quite behaving transparently; non-view URLs are also being redirected to the raw view page, so for instance an ?action=edit or diff or whatever gets lost.

See for example:
http://en.wikipedia.org/wiki/Image:Wiki.png?action=edit
http://en.wikipedia.org/wiki/Media:Wiki.png?action=edit

these both currently behave just like:
http://en.wikipedia.org/wiki/File:Wiki.png?action=edit

while with this patch the Media: one would unexpectedly redirect to the view URL.

The redirection should probably just be done where other existing normalization is... perhaps all that's actually needed is just to replace a Media: Title with the equivalent File: one when initializing the title in the first place, and the existing normalization-redirection will take care of it.
Modified paths:
  • /trunk/phase3/includes/Wiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Wiki.php
@@ -218,10 +218,6 @@
219219 } else if( NS_SPECIAL == $title->getNamespace() ) {
220220 /* actions that need to be made when we have a special pages */
221221 SpecialPage::executePath( $title );
222 - } else if( NS_MEDIA == $title->getNamespace() ) {
223 - global $wgOut;
224 - $fileTitle = Title::makeTitle( NS_FILE, $title->getDBKey() );
225 - $wgOut->redirect( $fileTitle->getFullUrl() );
226222 } else {
227223 /* Try low-level file cache hit */
228224 if( $title->getNamespace() != NS_MEDIAWIKI && HTMLFileCache::useFileCache() ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r44972(Bug 16677) Media: view URLs should HTTP-redirect to canonical File: namespaceaaron21:05, 23 December 2008

Comments

#Comment by Krinkle (talk | contribs)   23:16, 9 October 2011

A way to preserve the query would be nice :)

During ResourceLoader2 I attempted to redirect Special:Gadgets/ to Special:Gadgets (in case no sub page parameter is provided), but I undid that because depending on the implementation I either got stuck with an infinite redirect of a lot of bogus in the url.

I use OutputPage::redirect, Title:getFullUrl and something with WebRequest::getQueryValues.

The problem was that the 'title' query parameter was someone ending up being added after the one in the current url, and the one in the current url via mod_rewrite/articlepath is internally interpreted as 'title' as well. So the URL looked like title=Special:Gadgets/&title=Special:Gadgets. I tried unsetting ['title'] but somehow got re-added.

A way to redirect to a title with an option to preserve query (and still have it be fixed afterwards to apply article/action paths were relevant) would be really nice :)

Status & tagging log