+ list( $msg, $code ) = $this->figureMessage( $title );
+
+ $cacheKey = wfMemcKey( 'messages', $code );
+ $this->load( $code );
+ $this->lock( $cacheKey );
+
+ $titleKey = wfMemcKey( 'messages', 'individual', $title );
+
+ if ( $text === false ) {
+ # Article was deleted
+ $this->mCache[$code][$title] = '!NONEXISTENT';
+ $this->mMemc->delete( $titleKey );
+
+ } elseif ( strlen( $text ) > $wgMaxMsgCacheEntrySize ) {
+ # Check for size
+ $this->mCache[$code][$title] = '!TOO BIG';
+ $this->mMemc->set( $titleKey, ' ' . $text, $this->mExpiry );
+
+ } else {
+ $this->mCache[$code][$title] = ' ' . $text;
+ $this->mMemc->delete( $titleKey );
+ }
+
+ # Update caches
+ $this->saveToCaches( $this->mCache[$code], true, $code );
+ $this->unlock( $cacheKey );
+
+ // Also delete cached sidebar... just in case it is affected
+ $codes = array( $code );
+ if ( $code === 'en' ) {
+ // Delete all sidebars, like for example on action=purge on the
+ // sidebar messages
+ $codes = array_keys( Language::getLanguageNames() );
+ }
+
+ global $parserMemc;
+ foreach ( $codes as $code ) {
+ $sidebarKey = wfMemcKey( 'sidebar', $code );
+ $parserMemc->delete( $sidebarKey );
+ }
+
+ // Update the message in the message blob store
+ global $wgContLang;
+ MessageBlobStore::updateMessage( $wgContLang->lcfirst( $msg ) );
+
+ wfRunHooks( "MessageCacheReplace", array( $title, $text ) );
+
+ wfProfileOut( __METHOD__ );
+ }