From ecc8114014ce16bd12b780e7ebbeaf10810b15b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Roquet?= Date: Mon, 13 May 2013 00:10:47 +0200 Subject: [PATCH] Add Special:Diff as an internally-linkable redirect to diff pages MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is similar to Special:PermanentLink added in r79036 and has been asked for several times in different places, including: - on the English Wikipedia (oldid=539308532) - on mediawiki.org (lqt_oldid=31691) - on the French Wikipedia (oldid=93029892) - on the English Wikipedia again (oldid=588408888) A notable use-case is linking to diffs in the edit summaries, where external links are not yet allowed (bug 14892). All of the following are valid usages: - [[Special:Diff/12345]] (diff of a revision with the previous one) - [[Special:Diff/12345/prev]] (diff of a revision with the previous one as well) - [[Special:Diff/12345/next]] (diff of a revision with the next one) - [[Special:Diff/12345/cur]] (diff of a revision with the latest one of that page) - [[Special:Diff/12345/98765]] (diff between arbitrary two revisions) Co-authored-by: Jérémie Roquet Co-authored-by: Bartosz Dziewoński Change-Id: I77fdaf8e04375caa1d67ca4a3ec3bd93920c3309 --- RELEASE-NOTES-1.23 | 3 + includes/AutoLoader.php | 1 + includes/specialpage/SpecialPageFactory.php | 1 + includes/specials/SpecialDiff.php | 61 +++++++++++++++++++++ languages/messages/MessagesEn.php | 1 + 5 files changed, 67 insertions(+) create mode 100644 includes/specials/SpecialDiff.php diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index b80a9a9ce7..7aecdb9156 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -75,6 +75,9 @@ production. * WikitextContent will now render redirects with the expected "redirect" header, rather than as an ordered list. Code calling Article::viewRedirect can probably be changed to no longer special-case redirects. +* [[Special:Diff]] was added, allowing users to create internal links to + revision comparison pages using syntax such as [[Special:Diff/12345]], + [[Special:Diff/12345/prev]] or [[Special:Diff/12345/98765]]. === Bug fixes in 1.23 === * (bug 41759) The "updated since last visit" markers (on history pages, recent diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 91fa55fb44..192d071a9a 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -965,6 +965,7 @@ $wgAutoloadLocalClasses = array( 'SpecialChangePassword' => 'includes/specials/SpecialChangePassword.php', 'SpecialComparePages' => 'includes/specials/SpecialComparePages.php', 'SpecialContributions' => 'includes/specials/SpecialContributions.php', + 'SpecialDiff' => 'includes/specials/SpecialDiff.php', 'SpecialEditWatchlist' => 'includes/specials/SpecialEditWatchlist.php', 'SpecialEmailUser' => 'includes/specials/SpecialEmailuser.php', 'SpecialExpandTemplates' => 'includes/specials/SpecialExpandTemplates.php', diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php index dcf5f67b78..792d0a64ef 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -154,6 +154,7 @@ class SpecialPageFactory { // Unlisted / redirects 'Blankpage' => 'SpecialBlankpage', + 'Diff' => 'SpecialDiff', 'Emailuser' => 'SpecialEmailUser', 'Movepage' => 'MovePageForm', 'Mycontributions' => 'SpecialMycontributions', diff --git a/includes/specials/SpecialDiff.php b/includes/specials/SpecialDiff.php new file mode 100644 index 0000000000..bc0d7e3b85 --- /dev/null +++ b/includes/specials/SpecialDiff.php @@ -0,0 +1,61 @@ +mAllowedRedirectParams = array(); + } + + function getRedirect( $subpage ) { + $parts = explode( '/', $subpage ); + + // Try to parse the values given, generating somewhat pretty URLs if possible + if ( count( $parts ) === 1 ) { + $this->mAddedRedirectParams['diff'] = $parts[0]; + } elseif ( count( $parts ) === 2 ) { + $this->mAddedRedirectParams['oldid'] = $parts[0]; + $this->mAddedRedirectParams['diff'] = $parts[1]; + } else { + // Wrong number of parameters, bail out + throw new ErrorPageError( 'nopagetitle', 'nopagetext' ); + } + + return true; + } +} diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index a3ff563c98..89b0fdc088 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -404,6 +404,7 @@ $specialPageAliases = array( 'CreateAccount' => array( 'CreateAccount' ), 'Deadendpages' => array( 'DeadendPages' ), 'DeletedContributions' => array( 'DeletedContributions' ), + 'Diff' => array( 'Diff' ), 'DoubleRedirects' => array( 'DoubleRedirects' ), 'EditWatchlist' => array( 'EditWatchlist' ), 'Emailuser' => array( 'EmailUser' ), -- 2.20.1