Also refactor SpecialPage::getRedirectQuery() to return an associative array to pass to wfArrayToCGI(), rather than bodging the query string together internally.
'Mypage' => 'SpecialMypage',
'Mytalk' => 'SpecialMytalk',
'Myuploads' => 'SpecialMyuploads',
'Mypage' => 'SpecialMypage',
'Mytalk' => 'SpecialMytalk',
'Myuploads' => 'SpecialMyuploads',
+ 'PermanentLink' => 'SpecialPermanentLink',
'Revisiondelete' => 'SpecialRevisionDelete',
'RevisionMove' => 'SpecialRevisionMove',
'Specialpages' => 'SpecialSpecialpages',
'Revisiondelete' => 'SpecialRevisionDelete',
'RevisionMove' => 'SpecialRevisionMove',
'Specialpages' => 'SpecialSpecialpages',
# Check for redirect
if ( !$including ) {
$redirect = $page->getRedirect( $par );
# Check for redirect
if ( !$including ) {
$redirect = $page->getRedirect( $par );
- if ( $redirect ) {
- $query = $page->getRedirectQuery();
+ $query = $page->getRedirectQuery();
+ if ( $redirect instanceof Title ) {
$url = $redirect->getFullUrl( $query );
$wgOut->redirect( $url );
wfProfileOut( __METHOD__ );
return $redirect;
$url = $redirect->getFullUrl( $query );
$wgOut->redirect( $url );
wfProfileOut( __METHOD__ );
return $redirect;
+ } elseif( $redirect === true ) {
+ global $wgScript;
+ $url = $wgScript . '?' . wfArrayToCGI( $query );
+ $wgOut->redirect( $url );
+ wfProfileOut( __METHOD__ );
+ return $redirect;
function getRedirectQuery() {
global $wgRequest;
$params = array();
function getRedirectQuery() {
global $wgRequest;
$params = array();
foreach( $this->mAllowedRedirectParams as $arg ) {
foreach( $this->mAllowedRedirectParams as $arg ) {
- if( ( $val = $wgRequest->getVal( $arg, null ) ) !== null )
- $params[] = $arg . '=' . $val;
+ if( $wgRequest->getVal( $arg, null ) !== null ){
+ $params[$arg] = $wgRequest->getVal( $arg );
+ }
foreach( $this->mAddedRedirectParams as $arg => $val ) {
foreach( $this->mAddedRedirectParams as $arg => $val ) {
- $params[] = $arg . '=' . $val;
-
- return count( $params ) ? implode( '&', $params ) : false;
+
+ return count( $params )
+ ? $params
+ : false;
-/** SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
+/**
+ * SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
* are used to get user independant links pointing to the user page, talk
* page and list of contributions.
* This can let us cache a single copy of any generated content for all
* are used to get user independant links pointing to the user page, talk
* page and list of contributions.
* This can let us cache a single copy of any generated content for all
parent::__construct( 'Myuploads' );
$this->mAllowedRedirectParams = array( 'limit' );
}
parent::__construct( 'Myuploads' );
$this->mAllowedRedirectParams = array( 'limit' );
}
function getRedirect( $subpage ) {
global $wgUser;
return SpecialPage::getTitleFor( 'Listfiles', $wgUser->getName() );
}
}
function getRedirect( $subpage ) {
global $wgUser;
return SpecialPage::getTitleFor( 'Listfiles', $wgUser->getName() );
}
}
+
+/**
+ * Redirect to Special:Listfiles?user=$wgUser
+ */
+class SpecialPermanentLink extends UnlistedSpecialPage {
+ function __construct() {
+ parent::__construct( 'PermanentLink' );
+ $this->mAllowedRedirectParams = array();
+ }
+
+ function getRedirect( $subpage ) {
+ $subpage = intval( $subpage );
+ $this->mAddedRedirectParams['oldid'] = $subpage;
+ return true;
+ }
+}
'Mytalk' => array( 'MyTalk' ),
'Mycontributions' => array( 'MyContributions' ),
'Myuploads' => array( 'MyUploads' ),
'Mytalk' => array( 'MyTalk' ),
'Mycontributions' => array( 'MyContributions' ),
'Myuploads' => array( 'MyUploads' ),
+ 'PermanentLink' => array( 'PermanentLink' ),
'Listadmins' => array( 'ListAdmins' ),
'Listbots' => array( 'ListBots' ),
'Popularpages' => array( 'PopularPages' ),
'Listadmins' => array( 'ListAdmins' ),
'Listbots' => array( 'ListBots' ),
'Popularpages' => array( 'PopularPages' ),