getRedirect( $subpage ); $query = $this->getRedirectQuery(); // Redirect to a page title with possible query parameters if ( $redirect instanceof Title ) { $url = $redirect->getFullUrlForRedirect( $query ); $this->getOutput()->redirect( $url ); return $redirect; } elseif ( $redirect === true ) { // Redirect to index.php with query parameters $url = wfAppendQuery( wfScript( 'index' ), $query ); $this->getOutput()->redirect( $url ); return $redirect; } else { $this->showNoRedirectPage(); } } /** * If the special page is a redirect, then get the Title object it redirects to. * False otherwise. * * @param string|null $subpage * @return Title|bool */ abstract public function getRedirect( $subpage ); /** * Return part of the request string for a special redirect page * This allows passing, e.g. action=history to Special:Mypage, etc. * * @return array|bool */ public function getRedirectQuery() { $params = []; $request = $this->getRequest(); foreach ( array_merge( $this->mAllowedRedirectParams, [ 'uselang', 'useskin', 'debug' ] // parameters which can be passed to all pages ) as $arg ) { if ( $request->getVal( $arg, null ) !== null ) { $params[$arg] = $request->getVal( $arg ); } elseif ( $request->getArray( $arg, null ) !== null ) { $params[$arg] = $request->getArray( $arg ); } } foreach ( $this->mAddedRedirectParams as $arg => $val ) { $params[$arg] = $val; } return count( $params ) ? $params : false; } /** * Indicate if the target of this redirect can be used to identify * a particular user of this wiki (e.g., if the redirect is to the * user page of a User). See T109724. * * @since 1.27 * @return bool */ public function personallyIdentifiableTarget() { return false; } protected function showNoRedirectPage() { $class = static::class; throw new MWException( "RedirectSpecialPage $class doesn't redirect!" ); } }