From: Bartosz DziewoƄski Date: Thu, 8 Aug 2019 19:45:04 +0000 (+0200) Subject: RedirectSpecialArticle: Avoid double redirect for action=edit&redlink=1 X-Git-Tag: 1.34.0-rc.0~733 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=68558351c835c577fb8eb504aa96822a1dff1e7b;p=lhc%2Fweb%2Fwiklou.git 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 --- 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; + } + }