Index: trunk/phase3/includes/LocalisationCache.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -define( 'MW_LC_VERSION', 1 ); |
| 4 | +define( 'MW_LC_VERSION', 2 ); |
5 | 5 | |
6 | 6 | /** |
7 | 7 | * Class for caching the contents of localisation files, Messages*.php |
— | — | @@ -485,7 +485,6 @@ |
486 | 486 | * and save it to the persistent cache store and the process cache |
487 | 487 | */ |
488 | 488 | public function recache( $code ) { |
489 | | - static $recursionGuard = array(); |
490 | 489 | global $wgExtensionMessagesFiles, $wgExtensionAliasesFiles; |
491 | 490 | wfProfileIn( __METHOD__ ); |
492 | 491 | |
— | — | @@ -522,27 +521,27 @@ |
523 | 522 | $coreData['fallback'] = $code === 'en' ? false : 'en'; |
524 | 523 | } |
525 | 524 | |
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'; |
530 | 533 | } |
531 | | - $recursionGuard[$code] = true; |
532 | 534 | |
533 | 535 | # 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 | + } |
539 | 543 | } |
540 | 544 | } |
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 | + |
547 | 546 | } |
548 | 547 | $codeSequence = array_merge( array( $code ), $coreData['fallbackSequence'] ); |
549 | 548 | |