Index: trunk/phase3/includes/MessageCache.php |
— | — | @@ -376,38 +376,38 @@ |
377 | 377 | global $wgMaxMsgCacheEntrySize; |
378 | 378 | wfProfileIn( __METHOD__ ); |
379 | 379 | |
| 380 | + if ( $this->mDisable ) { |
| 381 | + return; |
| 382 | + } |
380 | 383 | |
381 | 384 | list( , $code ) = $this->figureMessage( $title ); |
382 | 385 | |
383 | 386 | $cacheKey = wfMemcKey( 'messages', $code ); |
384 | | - $this->load($code); |
385 | | - $this->lock($cacheKey); |
| 387 | + $this->load( $code ); |
| 388 | + $this->lock( $cacheKey ); |
386 | 389 | |
387 | | - if ( is_array($this->mCache[$code]) ) { |
388 | | - $titleKey = wfMemcKey( 'messages', 'individual', $title ); |
| 390 | + $titleKey = wfMemcKey( 'messages', 'individual', $title ); |
389 | 391 | |
390 | | - if ( $text === false ) { |
391 | | - # Article was deleted |
392 | | - unset( $this->mCache[$code][$title] ); |
393 | | - $this->mMemc->delete( $titleKey ); |
| 392 | + if ( $text === false ) { |
| 393 | + # Article was deleted |
| 394 | + $this->mCache[$code][$title] = '!NONEXISTENT'; |
| 395 | + $this->mMemc->delete( $titleKey ); |
394 | 396 | |
395 | | - } elseif ( strlen( $text ) > $wgMaxMsgCacheEntrySize ) { |
396 | | - # Check for size |
397 | | - $this->mCache[$code][$title] = '!TOO BIG'; |
398 | | - $this->mMemc->set( $titleKey, ' ' . $text, $this->mExpiry ); |
| 397 | + } elseif ( strlen( $text ) > $wgMaxMsgCacheEntrySize ) { |
| 398 | + # Check for size |
| 399 | + $this->mCache[$code][$title] = '!TOO BIG'; |
| 400 | + $this->mMemc->set( $titleKey, ' ' . $text, $this->mExpiry ); |
399 | 401 | |
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 ); |
| 402 | + } else { |
| 403 | + $this->mCache[$code][$title] = ' ' . $text; |
| 404 | + $this->mMemc->delete( $titleKey ); |
407 | 405 | } |
408 | | - $this->unlock($cacheKey); |
409 | 406 | |
| 407 | + # Update caches |
| 408 | + $this->saveToCaches( $this->mCache[$code], true, $code ); |
| 409 | + $this->unlock( $cacheKey ); |
| 410 | + |
410 | 411 | // Also delete cached sidebar... just in case it is affected |
411 | | - global $parserMemc; |
412 | 412 | $codes = array( $code ); |
413 | 413 | if ( $code === 'en' ) { |
414 | 414 | // Delete all sidebars, like for example on action=purge on the |
— | — | @@ -415,6 +415,7 @@ |
416 | 416 | $codes = array_keys( Language::getLanguageNames() ); |
417 | 417 | } |
418 | 418 | |
| 419 | + global $parserMemc; |
419 | 420 | foreach ( $codes as $code ) { |
420 | 421 | $sidebarKey = wfMemcKey( 'sidebar', $code ); |
421 | 422 | $parserMemc->delete( $sidebarKey ); |
— | — | @@ -592,11 +593,12 @@ |
593 | 594 | $message = false; |
594 | 595 | |
595 | 596 | $this->load( $code ); |
596 | | - if (isset( $this->mCache[$code][$title] ) ) { |
| 597 | + if ( isset( $this->mCache[$code][$title] ) ) { |
597 | 598 | $entry = $this->mCache[$code][$title]; |
598 | | - $type = substr( $entry, 0, 1 ); |
599 | | - if ( $type == ' ' ) { |
| 599 | + if ( substr( $entry, 0, 1 ) === ' ' ) { |
600 | 600 | return substr( $entry, 1 ); |
| 601 | + } elseif ( $entry === '!NONEXISTENT' ) { |
| 602 | + return false; |
601 | 603 | } |
602 | 604 | } |
603 | 605 | |
— | — | @@ -606,24 +608,15 @@ |
607 | 609 | return $message; |
608 | 610 | } |
609 | 611 | |
610 | | - # If there is no cache entry and no placeholder, it doesn't exist |
611 | | - if ( $type !== '!' ) { |
612 | | - return false; |
613 | | - } |
614 | | - |
615 | | - $titleKey = wfMemcKey( 'messages', 'individual', $title ); |
616 | | - |
617 | 612 | # Try the individual message cache |
| 613 | + $titleKey = wfMemcKey( 'messages', 'individual', $title ); |
618 | 614 | $entry = $this->mMemc->get( $titleKey ); |
619 | 615 | if ( $entry ) { |
620 | | - $type = substr( $entry, 0, 1 ); |
621 | | - |
622 | | - if ( $type === ' ' ) { |
623 | | - # Ok! |
624 | | - $message = substr( $entry, 1 ); |
| 616 | + if ( substr( $entry, 0, 1 ) === ' ' ) { |
625 | 617 | $this->mCache[$code][$title] = $entry; |
626 | | - return $message; |
| 618 | + return substr( $entry, 1 ); |
627 | 619 | } elseif ( $entry === '!NONEXISTENT' ) { |
| 620 | + $this->mCache[$code][$title] = '!NONEXISTENT'; |
628 | 621 | return false; |
629 | 622 | } else { |
630 | 623 | # Corrupt/obsolete entry, delete it |
— | — | @@ -631,18 +624,17 @@ |
632 | 625 | } |
633 | 626 | } |
634 | 627 | |
635 | | - # Try loading it from the DB |
| 628 | + # Try loading it from the database |
636 | 629 | $revision = Revision::newFromTitle( Title::makeTitle( NS_MEDIAWIKI, $title ) ); |
637 | | - if( $revision ) { |
| 630 | + if ( $revision ) { |
638 | 631 | $message = $revision->getText(); |
639 | 632 | $this->mCache[$code][$title] = ' ' . $message; |
640 | 633 | $this->mMemc->set( $titleKey, ' ' . $message, $this->mExpiry ); |
641 | 634 | } else { |
642 | | - # Negative caching |
643 | | - # Use some special text instead of false, because false gets converted to '' somewhere |
| 635 | + $this->mCache[$code][$title] = '!NONEXISTENT'; |
644 | 636 | $this->mMemc->set( $titleKey, '!NONEXISTENT', $this->mExpiry ); |
645 | | - $this->mCache[$code][$title] = false; |
646 | 637 | } |
| 638 | + |
647 | 639 | return $message; |
648 | 640 | } |
649 | 641 | |