Localisation updates for core and extension messages from translatewiki.net (2010...
[lhc/web/wiklou.git] / includes / Wiki.php
index 9e16535..feebcde 100644 (file)
@@ -109,7 +109,8 @@ class MediaWiki {
                        $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' ) {
@@ -179,9 +180,8 @@ class MediaWiki {
         */
        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() == '' ) ) ) {
@@ -192,7 +192,8 @@ class MediaWiki {
 
                // 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();
@@ -209,19 +210,17 @@ class MediaWiki {
                                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" .
@@ -379,6 +378,8 @@ class MediaWiki {
                $output->output();
                // Do any deferred jobs
                $this->doUpdates( $deferredUpdates );
+               // Close the session so that jobs don't access the current session
+               session_write_close();
                $this->doJobs();
                wfProfileOut( __METHOD__ );
        }
@@ -449,6 +450,7 @@ class MediaWiki {
         * Ends this task peacefully
         */
        function restInPeace() {
+               MessageCache::logMessages();
                wfLogProfilingData();
                // Commit and close up!
                $factory = wfGetLBFactory();