Construct clean canonical URLs for wiki pages, ignoring request URL


Construct clean canonical URLs for wiki pages, ignoring request URL

Canonical URLs allow webmasters to indicate the preferred URL form for
accessing some content that can be reached via a multitude of URL patterns.
It is usually (but not always) distinct from the request URL, which may
feature things like aliases and session-specific query parameters.
We currently derive canonical URLs from request URLs, which is backwards:
it is the web application, not the client, that ought to know the canonical
way to refer to some content.

This patch ensures MediaWiki derives a clean canonical URL for all wiki
pages from the request context's title object and action.

For some assurance that this is the correct approach, see:


This Google blog post identifies Wikia as exemplary in its usage of canonical
URLs. Wikia disregards things like the requested revision ID (oldid=NNN) when
constructing the canonical URL. See, for example:


Wikia goes as far as canonicalizing the action=history to the page view URL.
I think that this is incorrect, because the history and info actions are not
views of the page content, but rather its associated metadata.

This affects all requests where "setArticleRelated" is true. This is typically
all urls that show content (title query, curid, oldid, diff), and all actions
thereof (edit, delete, purge, info, history etc.). It does not apply to
File pages and Special pages.

Bug: T67402
Change-Id: I1549ca056637981a0d751020c634b9fab387f7bc


oriAuthored on
KrinkleCommitted on Jun 22 2015, 5:45 PM
rMWcd618c1bfd1c: Localisation updates from https://translatewiki.net.