r94991 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94990‎ | r94991 | r94992 >
Date:09:02, 19 August 2011
Author:nikerabbit
Status:ok (Comments)
Tags:
Comment:
Fu r94907 - also update localisation cache, which accesses the fallback variable directly
Fixes bug 30456
Modified paths:
  • /trunk/phase3/includes/LocalisationCache.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LocalisationCache.php
@@ -1,6 +1,6 @@
22 <?php
33
4 -define( 'MW_LC_VERSION', 1 );
 4+define( 'MW_LC_VERSION', 2 );
55
66 /**
77 * Class for caching the contents of localisation files, Messages*.php
@@ -485,7 +485,6 @@
486486 * and save it to the persistent cache store and the process cache
487487 */
488488 public function recache( $code ) {
489 - static $recursionGuard = array();
490489 global $wgExtensionMessagesFiles, $wgExtensionAliasesFiles;
491490 wfProfileIn( __METHOD__ );
492491
@@ -522,27 +521,27 @@
523522 $coreData['fallback'] = $code === 'en' ? false : 'en';
524523 }
525524
526 - if ( $coreData['fallback'] !== false ) {
527 - # Guard against circular references
528 - if ( isset( $recursionGuard[$code] ) ) {
529 - throw new MWException( "Error: Circular fallback reference in language code $code" );
 525+ if ( $coreData['fallback'] === false ) {
 526+ $coreData['fallbackSequence'] = array();
 527+ } else {
 528+ $coreData['fallbackSequence'] = array_map( 'trim', explode( ',', $coreData['fallback'] ) );
 529+ $len = count( $coreData['fallbackSequence'] );
 530+ # Ensure that the sequence ends at en
 531+ if ( $coreData['fallbackSequence'][$len - 1] !== 'en' ) {
 532+ $coreData['fallbackSequence'][] = 'en';
530533 }
531 - $recursionGuard[$code] = true;
532534
533535 # Load the fallback localisation item by item and merge it
534 - $deps = array_merge( $deps, $this->getItem( $coreData['fallback'], 'deps' ) );
535 - foreach ( self::$allKeys as $key ) {
536 - if ( is_null( $coreData[$key] ) || $this->isMergeableKey( $key ) ) {
537 - $fallbackValue = $this->getItem( $coreData['fallback'], $key );
538 - $this->mergeItem( $key, $coreData[$key], $fallbackValue );
 536+ foreach ( $coreData['fallbackSequence'] as $fallback ) {
 537+ $deps = array_merge( $deps, $this->getItem( $fallback, 'deps' ) );
 538+ foreach ( self::$allKeys as $key ) {
 539+ if ( is_null( $coreData[$key] ) || $this->isMergeableKey( $key ) ) {
 540+ $fallbackValue = $this->getItem( $fallback, $key );
 541+ $this->mergeItem( $key, $coreData[$key], $fallbackValue );
 542+ }
539543 }
540544 }
541 - $fallbackSequence = $this->getItem( $coreData['fallback'], 'fallbackSequence' );
542 - array_unshift( $fallbackSequence, $coreData['fallback'] );
543 - $coreData['fallbackSequence'] = $fallbackSequence;
544 - unset( $recursionGuard[$code] );
545 - } else {
546 - $coreData['fallbackSequence'] = array();
 545+
547546 }
548547 $codeSequence = array_merge( array( $code ), $coreData['fallbackSequence'] );
549548

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94907Attempt to fix Bug 30216 - Improve language fallback loop detection....nikerabbit16:41, 18 August 2011

Comments

#Comment by Hashar (talk | contribs)   09:55, 19 August 2011

While you are poking this code, could you possibly add a comment describing MW_LC_VERSION ? :)

#Comment by Nikerabbit (talk | contribs)   09:58, 19 August 2011

Uhhuh. I actually don't know what it does. I *assume* changing it forces the caches to be rebuilt.

#Comment by Hashar (talk | contribs)   12:02, 19 August 2011
# Add cache dependencies for any referenced globals
...
$deps['version'] = new ConstantDependency( 'MW_LC_VERSION' );

Which is then used by the function isExpired().

So your assumption seems to be true.

#Comment by He7d3r (talk | contribs)   13:55, 19 August 2011
#Comment by Siebrand (talk | contribs)   14:34, 25 August 2011

Issue is not confirmed fixed by the reporter.

#Comment by Siebrand (talk | contribs)   14:34, 25 August 2011

Sorry: Issue is now confirmed fixed by the reporter.

Status & tagging log