This will make it easier to create redirects where $subpage is the title,
e.g. "Special:Example/Foo?x=y" to "index.php?title=Foo&x=y".
To do that conveniently, getRedirectQuery() needs access to $subpage.
The alternative is to do Title-parsing inside getRedirect(), which then
complicates this significantly as one has to deal with absence of a title
(null) and invalid titles (illegal chars etc.).
By using it plainly as query parameter (defaulting to null/omitted), this
is all deferred to index.php, which seems like a better separation of
concerns.
Motivated by SpecialMobileHistory in MobileFrontend (Ic0aea7ee340a).
Change-Id: I9fe78f479053fb55952ba78850d2fc281a039fe3
$target = $specialPage->getRedirect( $subpage );
// target can also be true. We let that case fall through to normal processing.
if ( $target instanceof Title ) {
$target = $specialPage->getRedirect( $subpage );
// target can also be true. We let that case fall through to normal processing.
if ( $target instanceof Title ) {
- $query = $specialPage->getRedirectQuery() ?: [];
+ $query = $specialPage->getRedirectQuery( $subpage ) ?: [];
$request = new DerivativeRequest( $this->context->getRequest(), $query );
$request->setRequestURL( $this->context->getRequest()->getRequestURL() );
$this->context->setRequest( $request );
$request = new DerivativeRequest( $this->context->getRequest(), $query );
$request->setRequestURL( $this->context->getRequest()->getRequestURL() );
$this->context->setRequest( $request );
*/
public function execute( $subpage ) {
$redirect = $this->getRedirect( $subpage );
*/
public function execute( $subpage ) {
$redirect = $this->getRedirect( $subpage );
- $query = $this->getRedirectQuery();
+ $query = $this->getRedirectQuery( $subpage );
if ( $redirect instanceof Title ) {
// Redirect to a page title with possible query parameters
if ( $redirect instanceof Title ) {
// Redirect to a page title with possible query parameters
* Return part of the request string for a special redirect page
* This allows passing, e.g. action=history to Special:Mypage, etc.
*
* Return part of the request string for a special redirect page
* This allows passing, e.g. action=history to Special:Mypage, etc.
*
+ * @param string|null $subpage
- public function getRedirectQuery() {
+ public function getRedirectQuery( $subpage ) {
$params = [];
$request = $this->getRequest();
$params = [];
$request = $this->getRequest();