Index: branches/wmf/1.17wmf1/includes/MessageCache.php |
— | — | @@ -376,38 +376,38 @@ |
377 | 377 | global $wgMaxMsgCacheEntrySize; |
378 | 378 | wfProfileIn( __METHOD__ ); |
379 | 379 | |
380 | | - if ( $this->mDisable ) { |
381 | | - return; |
382 | | - } |
383 | 380 | |
384 | 381 | list( $msg, $code ) = $this->figureMessage( $title ); |
385 | 382 | |
386 | 383 | $cacheKey = wfMemcKey( 'messages', $code ); |
387 | | - $this->load( $code ); |
388 | | - $this->lock( $cacheKey ); |
| 384 | + $this->load($code); |
| 385 | + $this->lock($cacheKey); |
389 | 386 | |
390 | | - $titleKey = wfMemcKey( 'messages', 'individual', $title ); |
| 387 | + if ( is_array($this->mCache[$code]) ) { |
| 388 | + $titleKey = wfMemcKey( 'messages', 'individual', $title ); |
391 | 389 | |
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 ); |
396 | 394 | |
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 ); |
401 | 399 | |
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 ); |
405 | 407 | } |
| 408 | + $this->unlock($cacheKey); |
406 | 409 | |
407 | | - # Update caches |
408 | | - $this->saveToCaches( $this->mCache[$code], true, $code ); |
409 | | - $this->unlock( $cacheKey ); |
410 | | - |
411 | 410 | // 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,7 +415,6 @@ |
416 | 416 | $codes = array_keys( Language::getLanguageNames() ); |
417 | 417 | } |
418 | 418 | |
419 | | - global $parserMemc; |
420 | 419 | foreach ( $codes as $code ) { |
421 | 420 | $sidebarKey = wfMemcKey( 'sidebar', $code ); |
422 | 421 | $parserMemc->delete( $sidebarKey ); |
— | — | @@ -603,12 +602,11 @@ |
604 | 603 | $message = false; |
605 | 604 | |
606 | 605 | $this->load( $code ); |
607 | | - if ( isset( $this->mCache[$code][$title] ) ) { |
| 606 | + if (isset( $this->mCache[$code][$title] ) ) { |
608 | 607 | $entry = $this->mCache[$code][$title]; |
609 | | - if ( substr( $entry, 0, 1 ) === ' ' ) { |
| 608 | + $type = substr( $entry, 0, 1 ); |
| 609 | + if ( $type == ' ' ) { |
610 | 610 | return substr( $entry, 1 ); |
611 | | - } elseif ( $entry === '!NONEXISTENT' ) { |
612 | | - return false; |
613 | 611 | } |
614 | 612 | } |
615 | 613 | |
— | — | @@ -618,15 +616,24 @@ |
619 | 617 | return $message; |
620 | 618 | } |
621 | 619 | |
| 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 | + |
622 | 627 | # Try the individual message cache |
623 | | - $titleKey = wfMemcKey( 'messages', 'individual', $title ); |
624 | 628 | $entry = $this->mMemc->get( $titleKey ); |
625 | 629 | 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 ); |
627 | 635 | $this->mCache[$code][$title] = $entry; |
628 | | - return substr( $entry, 1 ); |
| 636 | + return $message; |
629 | 637 | } elseif ( $entry === '!NONEXISTENT' ) { |
630 | | - $this->mCache[$code][$title] = '!NONEXISTENT'; |
631 | 638 | return false; |
632 | 639 | } else { |
633 | 640 | # Corrupt/obsolete entry, delete it |
— | — | @@ -634,17 +641,18 @@ |
635 | 642 | } |
636 | 643 | } |
637 | 644 | |
638 | | - # Try loading it from the database |
| 645 | + # Try loading it from the DB |
639 | 646 | $revision = Revision::newFromTitle( Title::makeTitle( NS_MEDIAWIKI, $title ) ); |
640 | | - if ( $revision ) { |
| 647 | + if( $revision ) { |
641 | 648 | $message = $revision->getText(); |
642 | 649 | $this->mCache[$code][$title] = ' ' . $message; |
643 | 650 | $this->mMemc->set( $titleKey, ' ' . $message, $this->mExpiry ); |
644 | 651 | } else { |
645 | | - $this->mCache[$code][$title] = '!NONEXISTENT'; |
| 652 | + # Negative caching |
| 653 | + # Use some special text instead of false, because false gets converted to '' somewhere |
646 | 654 | $this->mMemc->set( $titleKey, '!NONEXISTENT', $this->mExpiry ); |
| 655 | + $this->mCache[$code][$title] = false; |
647 | 656 | } |
648 | | - |
649 | 657 | return $message; |
650 | 658 | } |
651 | 659 | |