jenkins-bot has submitted this change and it was merged. Change subject: Add Special:Diff as an internally-linkable redirect to diff pages ......................................................................
Add Special:Diff as an internally-linkable redirect to diff pages 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 <[email protected]> Co-authored-by: Bartosz Dziewoński <[email protected]> Change-Id: I77fdaf8e04375caa1d67ca4a3ec3bd93920c3309 --- M RELEASE-NOTES-1.23 M includes/AutoLoader.php M includes/specialpage/SpecialPageFactory.php A includes/specials/SpecialDiff.php M languages/messages/MessagesEn.php 5 files changed, 67 insertions(+), 0 deletions(-) Approvals: Parent5446: Looks good to me, approved jenkins-bot: Verified diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index b80a9a9..7aecdb9 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -75,6 +75,9 @@ * 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 91fa55f..192d071 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -965,6 +965,7 @@ '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 dcf5f67..792d0a6 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -154,6 +154,7 @@ // 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 0000000..bc0d7e3 --- /dev/null +++ b/includes/specials/SpecialDiff.php @@ -0,0 +1,61 @@ +<?php +/** + * Redirect from Special:Diff/### to index.php?diff=### and + * from Special:Diff/###/### to index.php?oldid=###&diff=###. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @ingroup SpecialPage + */ + +/** + * Redirect from Special:Diff/### to index.php?diff=### and + * from Special:Diff/###/### to index.php?oldid=###&diff=###. + * + * 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) + * + * @ingroup SpecialPage + * @since 1.23 + */ +class SpecialDiff extends RedirectSpecialPage { + function __construct() { + parent::__construct( 'Diff' ); + $this->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 a3ff563..89b0fdc 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -404,6 +404,7 @@ 'CreateAccount' => array( 'CreateAccount' ), 'Deadendpages' => array( 'DeadendPages' ), 'DeletedContributions' => array( 'DeletedContributions' ), + 'Diff' => array( 'Diff' ), 'DoubleRedirects' => array( 'DoubleRedirects' ), 'EditWatchlist' => array( 'EditWatchlist' ), 'Emailuser' => array( 'EmailUser' ), -- To view, visit https://gerrit.wikimedia.org/r/63395 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I77fdaf8e04375caa1d67ca4a3ec3bd93920c3309 Gerrit-PatchSet: 13 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jérémie Roquet <[email protected]> Gerrit-Reviewer: Bartosz Dziewoński <[email protected]> Gerrit-Reviewer: Brian Wolff <[email protected]> Gerrit-Reviewer: Jérémie Roquet <[email protected]> Gerrit-Reviewer: Krinkle <[email protected]> Gerrit-Reviewer: Legoktm <[email protected]> Gerrit-Reviewer: MZMcBride <[email protected]> Gerrit-Reviewer: Parent5446 <[email protected]> Gerrit-Reviewer: Reedy <[email protected]> Gerrit-Reviewer: TMg <[email protected]> Gerrit-Reviewer: TheDJ <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
