From 21c7cd7109e177b2ab7e5b619bf6d314d8065e92 Mon Sep 17 00:00:00 2001 From: Stephane Bisson Date: Thu, 21 Dec 2017 09:38:21 -0500 Subject: [PATCH] RecentChangesLinked: Include title without subpage in form When the 'title' hidden field contains the subpage, the 'target' input field is never taken into account since the subpage always takes precedence in ChangesListSpecialPage->setup() I75cfb2b56a4da6357e6117b3f34f3178bfb2c90c introduced SpecialRecentChangesLinked->getPageTitle which overrides SpecialPage->getPageTitle to include the subpage by default. This helped with redirecting to the right page when parsing a saved query on the server but changed the behavior everywhere that function was used in the context of RCL. That includes SpecialRecentChanges.php:545 where the option form is built. Bug: T183437 Change-Id: Id39d1887719ecb6900b25fefbb133dff9c4d0456 --- includes/specialpage/ChangesListSpecialPage.php | 8 +++++--- .../specials/SpecialRecentchangeslinked.php | 17 ----------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 65a03eb767..303184de17 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -553,7 +553,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { public function execute( $subpage ) { $this->rcSubpage = $subpage; - $this->considerActionsForDefaultSavedQuery(); + $this->considerActionsForDefaultSavedQuery( $subpage ); $opts = $this->getOptions(); try { @@ -629,8 +629,10 @@ abstract class ChangesListSpecialPage extends SpecialPage { * Check whether or not the page should load defaults, and if so, whether * a default saved query is relevant to be redirected to. If it is relevant, * redirect properly with all necessary query parameters. + * + * @param string $subpage */ - protected function considerActionsForDefaultSavedQuery() { + protected function considerActionsForDefaultSavedQuery( $subpage ) { if ( !$this->isStructuredFilterUiEnabled() || $this->including() ) { return; } @@ -677,7 +679,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { // but are still valid and requested in the URL $query = array_merge( $this->getRequest()->getValues(), $query ); unset( $query[ 'title' ] ); - $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) ); + $this->getOutput()->redirect( $this->getPageTitle( $subpage )->getCanonicalURL( $query ) ); } else { // There's a default, but the version is not 2, and the server can't // actually recognize the query itself. This happens if it is before diff --git a/includes/specials/SpecialRecentchangeslinked.php b/includes/specials/SpecialRecentchangeslinked.php index 9e0daf55e5..d4aef6c0d1 100644 --- a/includes/specials/SpecialRecentchangeslinked.php +++ b/includes/specials/SpecialRecentchangeslinked.php @@ -30,8 +30,6 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { /** @var bool|Title */ protected $rclTargetTitle; - protected $rclTarget; - function __construct() { parent::__construct( 'Recentchangeslinked' ); } @@ -46,7 +44,6 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { public function parseParameters( $par, FormOptions $opts ) { $opts['target'] = $par; - $this->rclTarget = $par; } /** @@ -297,20 +294,6 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { return $this->prefixSearchString( $search, $limit, $offset ); } - /** - * Get a self-referential title object - * with consideration to the given subpage. - * - * @param string|bool $subpage - * @return Title - * @since 1.23 - */ - public function getPageTitle( $subpage = false ) { - $subpage = $subpage ? $subpage : $this->rclTarget; - - return parent::getPageTitle( $subpage ); - } - protected function outputNoResults() { if ( $this->getTargetTitle() === false ) { $this->getOutput()->addHTML( -- 2.20.1