From 68558351c835c577fb8eb504aa96822a1dff1e7b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Thu, 8 Aug 2019 21:45:04 +0200 Subject: [PATCH] RedirectSpecialArticle: Avoid double redirect for action=edit&redlink=1 If you visit `Special:MyPage?action=edit&redlink=1` and your user page exists, this would redirect to `User:Yourname?action=edit&redlink=1`, which then would redirect further to `User:Yourname`. Just redirect there directly. Additionally, the double-redirect seems to somehow conflict with the fake-redirect code for $wgHideIdentifiableRedirects. I couldn't figure out why this happens, but you end up on a blank page and no redirect of either kind occurs. Bug: T229794 Change-Id: I952fc9df91b1243db22f956ec09bee457c8a21bf --- .../specialpage/RedirectSpecialArticle.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/includes/specialpage/RedirectSpecialArticle.php b/includes/specialpage/RedirectSpecialArticle.php index b8dce3f5e0..27cd2ab4c3 100644 --- a/includes/specialpage/RedirectSpecialArticle.php +++ b/includes/specialpage/RedirectSpecialArticle.php @@ -106,4 +106,25 @@ abstract class RedirectSpecialArticle extends RedirectSpecialPage { Hooks::run( "RedirectSpecialArticleRedirectParams", [ &$redirectParams ] ); $this->mAllowedRedirectParams = $redirectParams; } + + /** + * @inheritDoc + */ + public function getRedirectQuery( $subpage ) { + $query = parent::getRedirectQuery( $subpage ); + $title = $this->getRedirect( $subpage ); + // Avoid double redirect for action=edit&redlink=1 for existing pages + // (compare to the check in EditPage::edit) + if ( + $query && + ( $query['action'] === 'edit' || $query['action'] === 'submit' ) && + (bool)$query['redlink'] && + $title instanceof Title && + $title->exists() + ) { + return false; + } + return $query; + } + } -- 2.20.1