Page MenuHomePhabricator

Special:RandomInCategory disregards query string
Closed, ResolvedPublicBUG REPORT

Description

First url preserves the wgAction but the second does not:

Because apparently they were written differently. Making the following change to ./specials/SpecialRandomInCategory.php seems to succeed:

@@ -142,11 +142,13 @@ class SpecialRandomInCategory extends FormSpecialPage {
 				$this->category->getText() );
 
 			return Status::newFatal( $msg );
 		}
 
-		$this->getOutput()->redirect( $title->getFullURL() );
+		$query = $this->getRequest()->getValues();
+		unset( $query['title'] );
+		$this->getOutput()->redirect( $title->getFullURL($query) );
 	}
 
 	/**
 	 * Choose a random title.
 	 * @return Title|null Title object (or null if nothing to choose from)

Event Timeline

Hi @Cobaltcigs, thanks for taking a look at the code!

You are very welcome to use developer access to submit the proposed code changes as a Git branch directly into Gerrit which makes it easier to review and provide feedback. If you don't want to set up Git/Gerrit, you can also use the Gerrit Patch Uploader. Thanks again!

Change 570999 had a related patch set uploaded (by Cobaltcigs; owner: Cobaltcigs):
[mediawiki/core@master] preserve query string for Special:RandomInCategory (T244641)

https://gerrit.wikimedia.org/r/570999

Change 570999 had a related patch set uploaded (by Cobaltcigs; owner: Cobaltcigs):
[mediawiki/core@master] SpecialRandomInCategory.php: preserve query string during redirection

https://gerrit.wikimedia.org/r/570999

Change 571064 had a related patch set uploaded (by Cobaltcigs; owner: Cobaltcigs):
[mediawiki/core@master] CategoryViewer.php: omit <h3> for whitespace sortkey header, improve vertical alignment of columns

https://gerrit.wikimedia.org/r/571064

Change 570999 merged by jenkins-bot:
[mediawiki/core@master] SpecialRandomInCategory.php: preserve query string during redirection

https://gerrit.wikimedia.org/r/570999

Ammarpad assigned this task to Cobaltcigs.