r81696 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81695‎ | r81696 | r81697 >
Date:07:08, 8 February 2011
Author:tstarling
Status:ok
Tags:
Comment:
Back out trunk r70657. It's broken without the $wgAdaptiveMessageCache-related followups, which were reverted.
Modified paths:
  • /branches/REL1_17/phase3/includes/MessageCache.php (modified) (history)

Diff [purge]

Index: branches/REL1_17/phase3/includes/MessageCache.php
@@ -376,38 +376,38 @@
377377 global $wgMaxMsgCacheEntrySize;
378378 wfProfileIn( __METHOD__ );
379379
380 - if ( $this->mDisable ) {
381 - return;
382 - }
383380
384381 list( $msg, $code ) = $this->figureMessage( $title );
385382
386383 $cacheKey = wfMemcKey( 'messages', $code );
387 - $this->load( $code );
388 - $this->lock( $cacheKey );
 384+ $this->load($code);
 385+ $this->lock($cacheKey);
389386
390 - $titleKey = wfMemcKey( 'messages', 'individual', $title );
 387+ if ( is_array($this->mCache[$code]) ) {
 388+ $titleKey = wfMemcKey( 'messages', 'individual', $title );
391389
392 - if ( $text === false ) {
393 - # Article was deleted
394 - $this->mCache[$code][$title] = '!NONEXISTENT';
395 - $this->mMemc->delete( $titleKey );
 390+ if ( $text === false ) {
 391+ # Article was deleted
 392+ unset( $this->mCache[$code][$title] );
 393+ $this->mMemc->delete( $titleKey );
396394
397 - } elseif ( strlen( $text ) > $wgMaxMsgCacheEntrySize ) {
398 - # Check for size
399 - $this->mCache[$code][$title] = '!TOO BIG';
400 - $this->mMemc->set( $titleKey, ' ' . $text, $this->mExpiry );
 395+ } elseif ( strlen( $text ) > $wgMaxMsgCacheEntrySize ) {
 396+ # Check for size
 397+ $this->mCache[$code][$title] = '!TOO BIG';
 398+ $this->mMemc->set( $titleKey, ' ' . $text, $this->mExpiry );
401399
402 - } else {
403 - $this->mCache[$code][$title] = ' ' . $text;
404 - $this->mMemc->delete( $titleKey );
 400+ } else {
 401+ $this->mCache[$code][$title] = ' ' . $text;
 402+ $this->mMemc->delete( $titleKey );
 403+ }
 404+
 405+ # Update caches
 406+ $this->saveToCaches( $this->mCache[$code], true, $code );
405407 }
 408+ $this->unlock($cacheKey);
406409
407 - # Update caches
408 - $this->saveToCaches( $this->mCache[$code], true, $code );
409 - $this->unlock( $cacheKey );
410 -
411410 // Also delete cached sidebar... just in case it is affected
 411+ global $parserMemc;
412412 $codes = array( $code );
413413 if ( $code === 'en' ) {
414414 // Delete all sidebars, like for example on action=purge on the
@@ -415,7 +415,6 @@
416416 $codes = array_keys( Language::getLanguageNames() );
417417 }
418418
419 - global $parserMemc;
420419 foreach ( $codes as $code ) {
421420 $sidebarKey = wfMemcKey( 'sidebar', $code );
422421 $parserMemc->delete( $sidebarKey );
@@ -603,12 +602,11 @@
604603 $message = false;
605604
606605 $this->load( $code );
607 - if ( isset( $this->mCache[$code][$title] ) ) {
 606+ if (isset( $this->mCache[$code][$title] ) ) {
608607 $entry = $this->mCache[$code][$title];
609 - if ( substr( $entry, 0, 1 ) === ' ' ) {
 608+ $type = substr( $entry, 0, 1 );
 609+ if ( $type == ' ' ) {
610610 return substr( $entry, 1 );
611 - } elseif ( $entry === '!NONEXISTENT' ) {
612 - return false;
613611 }
614612 }
615613
@@ -618,15 +616,24 @@
619617 return $message;
620618 }
621619
 620+ # If there is no cache entry and no placeholder, it doesn't exist
 621+ if ( $type !== '!' ) {
 622+ return false;
 623+ }
 624+
 625+ $titleKey = wfMemcKey( 'messages', 'individual', $title );
 626+
622627 # Try the individual message cache
623 - $titleKey = wfMemcKey( 'messages', 'individual', $title );
624628 $entry = $this->mMemc->get( $titleKey );
625629 if ( $entry ) {
626 - if ( substr( $entry, 0, 1 ) === ' ' ) {
 630+ $type = substr( $entry, 0, 1 );
 631+
 632+ if ( $type === ' ' ) {
 633+ # Ok!
 634+ $message = substr( $entry, 1 );
627635 $this->mCache[$code][$title] = $entry;
628 - return substr( $entry, 1 );
 636+ return $message;
629637 } elseif ( $entry === '!NONEXISTENT' ) {
630 - $this->mCache[$code][$title] = '!NONEXISTENT';
631638 return false;
632639 } else {
633640 # Corrupt/obsolete entry, delete it
@@ -634,17 +641,18 @@
635642 }
636643 }
637644
638 - # Try loading it from the database
 645+ # Try loading it from the DB
639646 $revision = Revision::newFromTitle( Title::makeTitle( NS_MEDIAWIKI, $title ) );
640 - if ( $revision ) {
 647+ if( $revision ) {
641648 $message = $revision->getText();
642649 $this->mCache[$code][$title] = ' ' . $message;
643650 $this->mMemc->set( $titleKey, ' ' . $message, $this->mExpiry );
644651 } else {
645 - $this->mCache[$code][$title] = '!NONEXISTENT';
 652+ # Negative caching
 653+ # Use some special text instead of false, because false gets converted to '' somewhere
646654 $this->mMemc->set( $titleKey, '!NONEXISTENT', $this->mExpiry );
 655+ $this->mCache[$code][$title] = false;
647656 }
648 -
649657 return $message;
650658 }
651659

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70657Allow negative caching in process cache and use it, return early in replace()...nikerabbit00:28, 8 August 2010

Status & tagging log