$wgOut->setPrintable();
}
$ret = null;
- if( $curid = $wgRequest->getInt( 'curid' ) ) {
+ $curid = $wgRequest->getInt( 'curid' );
+ if( $curid ) {
// URLs like this are generated by RC, because rc_title isn't always accurate
$ret = Title::newFromID( $curid );
} elseif( $title == '' && $action != 'delete' ) {
*/
function handleSpecialCases( &$title, &$output, $request ) {
wfProfileIn( __METHOD__ );
- global $wgContLang, $wgUser;
+
$action = $this->getVal( 'Action' );
- $perferred = $wgContLang->getPreferredVariant( false );
// Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
if( is_null($title) || ( ( $title->getDBkey() == '' ) && ( $title->getInterwiki() == '' ) ) ) {
// Interwiki redirects
} else if( $title->getInterwiki() != '' ) {
- if( $rdfrom = $request->getVal( 'rdfrom' ) ) {
+ $rdfrom = $request->getVal( 'rdfrom' );
+ if( $rdfrom ) {
$url = $title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
} else {
$query = $request->getValues();
throw new ErrorPageError( 'badtitle', 'badtitletext' );
}
// Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
- } else if( $action == 'view' && !$request->wasPosted() &&
- ( ( !$request->getVal( 'title' ) || $title->getPrefixedDBKey() != $request->getText( 'title' ) ) ||
- // No valid variant in URL (if the main-language has multi-variants), to ensure
- // anonymous access would always be redirect to a URL with 'variant' parameter
- ( !$request->getVal( 'variant' ) && $wgContLang->hasVariants() && !$wgUser->isLoggedIn() ) ) &&
- !count( array_diff( array_keys( $request->getValues() ), array( 'action', 'title' ) ) ) )
+ } else if ( $action == 'view' && !$request->wasPosted()
+ && ( $request->getVal( 'title' ) === null || $title->getPrefixedDBKey() != $request->getText( 'title' ) )
+ && !count( array_diff( array_keys( $request->getValues() ), array( 'action', 'title' ) ) ) )
{
- if( !$wgUser->isLoggedIn() ) {
- $pref = $wgContLang->getPreferredVariant( false, $fromHeader = true );
- $targetUrl = $title->getFullURL( '', $variant = $pref );
+ if ( $title->getNamespace() == NS_SPECIAL ) {
+ list( $name, $subpage ) = SpecialPage::resolveAliasWithSubpage( $title->getDBkey() );
+ if ( $name ) {
+ $title = SpecialPage::getTitleFor( $name, $subpage );
+ }
}
- else
- $targetUrl = $title->getFullURL();
+ $targetUrl = $title->getFullURL();
// Redirect to canonical url, make it a 301 to allow caching
if( $targetUrl == $request->getFullRequestURL() ) {
$message = "Redirect loop detected!\n\n" .