* ( bug 18264 ) upload-by-url form was still disabled in non-js2 form output
[lhc/web/wiklou.git] / includes / MessageCache.php
index 351c65d..2928117 100644 (file)
@@ -346,7 +346,7 @@ class MessageCache {
 
                $res = $dbr->select( array( 'page', 'revision', 'text' ),
                        array( 'page_title', 'old_text', 'old_flags' ),
-                       $smallConds, __METHOD__ );
+                       $smallConds, __METHOD__. "($code)" );
 
                for ( $row = $dbr->fetchObject( $res ); $row; $row = $dbr->fetchObject( $res ) ) {
                        $cache[$row->page_title] = ' ' . Revision::getRevisionText( $row );
@@ -400,8 +400,17 @@ class MessageCache {
 
                // Also delete cached sidebar... just in case it is affected
                global $parserMemc;
-               $sidebarKey = wfMemcKey( 'sidebar', $code );
-               $parserMemc->delete( $sidebarKey );
+               $codes = array( $code );
+               if ( $code === 'en'  ) {
+                       // Delete all sidebars, like for example on action=purge on the
+                       // sidebar messages
+                       $codes = array_keys( Language::getLanguageNames() );
+               }
+
+               foreach ( $codes as $code ) {
+                       $sidebarKey = wfMemcKey( 'sidebar', $code );
+                       $parserMemc->delete( $sidebarKey );
+               }
 
                wfRunHooks( "MessageCacheReplace", array( $title, $text ) );
 
@@ -423,16 +432,10 @@ class MessageCache {
 
                $cacheKey = wfMemcKey( 'messages', $code );
 
-               $i = 0;
                if ( $memc ) {
-                       # Save in memcached
-                       # Keep trying if it fails, this is kind of important
-
-                       for ($i=0; $i<20 &&
-                               !$this->mMemc->set( $cacheKey, $cache, $this->mExpiry );
-                               $i++ ) {
-                               usleep(mt_rand(500000,1500000));
-                       }
+                       $success = $this->mMemc->set( $cacheKey, $cache, $this->mExpiry );
+               } else {
+                       $success = true;
                }
 
                # Save to local cache
@@ -447,11 +450,6 @@ class MessageCache {
                        }
                }
 
-               if ( $i == 20 ) {
-                       $success = false;
-               } else {
-                       $success = true;
-               }
                wfProfileOut( __METHOD__ );
                return $success;
        }
@@ -511,10 +509,15 @@ class MessageCache {
 
                $message = false;
 
-               # Normalise title-case input
+               # Normalise title-case input (with some inlining)
                $lckey = str_replace( ' ', '_', $key );
-               $lckey[0] = strtolower( $lckey[0] );
-               $uckey = ucfirst( $lckey );
+               if ( ord( $key ) < 128 ) {
+                       $lckey[0] = strtolower( $lckey[0] );
+                       $uckey = ucfirst( $lckey );
+               } else {
+                       $lckey = $wgContLang->lcfirst( $lckey );
+                       $uckey = $wgContLang->ucfirst( $lckey );
+               }
 
                # Try the MediaWiki namespace
                if( !$this->mDisable && $useDB ) {