From: Tim Starling Date: Sat, 28 May 2005 11:49:40 +0000 (+0000) Subject: Unconditional inclusion for SpecialPage.php, needed for {{special:whatever}}. Fixed... X-Git-Tag: 1.5.0alpha2~60 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=225a20c35ac26b2a906490cf300441b011dfd485;p=lhc%2Fweb%2Fwiklou.git Unconditional inclusion for SpecialPage.php, needed for {{special:whatever}}. Fixed getRedirect() to work with this inclusion order. --- diff --git a/includes/Setup.php b/includes/Setup.php index 657dce71ba..f410371ec2 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -70,6 +70,7 @@ require_once( 'HistoryBlob.php' ); require_once( 'ProxyTools.php' ); require_once( 'ObjectCache.php' ); require_once( 'WikiError.php' ); +require_once( 'SpecialPage.php' ); if ( $wgUseDynamicDates ) { require_once( 'DateFormatter.php' ); diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index abfbcb9eae..301b9ddcad 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -19,7 +19,7 @@ /** * */ -global $wgSpecialPages, $wgSpecialPageRedirects, $wgUser; +global $wgSpecialPages, $wgUser; /** * @access private @@ -75,24 +75,6 @@ $wgSpecialPages = array( 'Groups' => new SpecialPage( 'Groups' ), ); -/** - * Redirect Special:$key to somewhere else. - * - * @access private - */ -$wgSpecialPageRedirects = array( - # My* - 'Mypage' => Title::makeTitle( NS_USER, $wgUser->getName() ), - 'Mytalk' => Title::makeTitle( NS_USER_TALK, $wgUser->getName() ), - 'Mycontributions' => Title::makeTitle( NS_SPECIAL, 'Contributions/' . $wgUser->getName() ), - - # Deprecated specialpages - 'Listadmins' => Title::makeTitle( NS_SPECIAL, 'Listusers' ), - - # Redirects - 'Randompage' => Title::makeTitle( NS_SPECIAL, 'Random' ), -); - global $wgUseValidation ; if ( $wgUseValidation ) $wgSpecialPages['Validate'] = new SpecialPage( 'Validate' ); @@ -198,11 +180,19 @@ class SpecialPage * @return mixed Title object if the redirect exists, otherwise NULL */ function &getRedirect( $name ) { - global $wgSpecialPageRedirects; - if ( array_key_exists( $name, $wgSpecialPageRedirects ) ) { - return $wgSpecialPageRedirects[$name]; - } else { - return NULL; + switch ( $name ) { + case 'Mypage': + return Title::makeTitle( NS_USER, $wgUser->getName() ); + case 'Mytalk': + return Title::makeTitle( NS_USER_TALK, $wgUser->getName() ); + case 'Mycontributions': + return Title::makeTitle( NS_SPECIAL, 'Contributions/' . $wgUser->getName() ); + case 'Listadmins': + return Title::makeTitle( NS_SPECIAL, 'Listusers' ); + case 'Randompage': + return Title::makeTitle( NS_SPECIAL, 'Random' ); + default: + return NULL; } } @@ -251,18 +241,22 @@ class SpecialPage $page =& SpecialPage::getPage( $name ); if ( is_null( $page ) ) { - $redir =& SpecialPage::getRedirect( $name ); - if ( isset( $redir ) ) { - if ( isset( $par ) ) - $wgOut->redirect( $redir->getFullURL() . '/' . $par ); - else - $wgOut->redirect( $redir->getFullURL() ); - $retVal = $redir; + if ( $including ) { + return false; } else { - $wgOut->setArticleRelated( false ); - $wgOut->setRobotpolicy( "noindex,follow" ); - $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" ); - $retVal = false; + $redir =& SpecialPage::getRedirect( $name ); + if ( isset( $redir ) ) { + if ( isset( $par ) ) + $wgOut->redirect( $redir->getFullURL() . '/' . $par ); + else + $wgOut->redirect( $redir->getFullURL() ); + $retVal = $redir; + } else { + $wgOut->setArticleRelated( false ); + $wgOut->setRobotpolicy( "noindex,follow" ); + $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" ); + $retVal = false; + } } } else { if ( $including && !$page->includable() ) { diff --git a/index.php b/index.php index 2dade97059..8f6fc3bc4a 100644 --- a/index.php +++ b/index.php @@ -134,7 +134,6 @@ if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) { $wgOut->redirect( $wgTitle->getFullURL(), '301'); } else if ( NS_SPECIAL == $wgTitle->getNamespace() ) { # actions that need to be made when we have a special pages - require_once( 'includes/SpecialPage.php' ); SpecialPage::executePath( $wgTitle ); } else { if ( NS_MEDIA == $wgTitle->getNamespace() ) {