r95192 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95191‎ | r95192 | r95193 >
Date:08:12, 22 August 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Make the language recaching non-recursive and load the data directly.
This might be a bit slower, but avoids problems with cyclic language fallbacks.
Followup r94907
Modified paths:
  • /trunk/phase3/includes/LocalisationCache.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LocalisationCache.php
@@ -514,6 +514,7 @@
515515 foreach ( $data as $key => $value ) {
516516 $this->mergeItem( $key, $coreData[$key], $value );
517517 }
 518+
518519 }
519520
520521 # Fill in the fallback if it's not there already
@@ -532,17 +533,24 @@
533534 }
534535
535536 # Load the fallback localisation item by item and merge it
536 - foreach ( $coreData['fallbackSequence'] as $fallback ) {
537 - $deps = array_merge( $deps, $this->getItem( $fallback, 'deps' ) );
 537+ foreach ( $coreData['fallbackSequence'] as $fbCode ) {
 538+
 539+ # Load the secondary localisation from the source file to
 540+ # avoid infinite cycles on cyclic fallbacks
 541+ $fbFilename = Language::getMessagesFileName( $fbCode );
 542+ if ( !file_exists( $fbFilename ) ) continue;
 543+
 544+ $deps[] = new FileDependency( $fbFilename );
 545+ $fbData = $this->readPHPFile( $fbFilename, 'core' );
538546 foreach ( self::$allKeys as $key ) {
 547+ if ( !isset( $fbData[$key] ) ) continue;
539548 if ( is_null( $coreData[$key] ) || $this->isMergeableKey( $key ) ) {
540 - $fallbackValue = $this->getItem( $fallback, $key );
541 - $this->mergeItem( $key, $coreData[$key], $fallbackValue );
 549+ $this->mergeItem( $key, $coreData[$key], $fbData[$key] );
542550 }
543551 }
544552 }
545 -
546553 }
 554+
547555 $codeSequence = array_merge( array( $code ), $coreData['fallbackSequence'] );
548556
549557 # Load the extension localisations

Past revisions this follows-up on

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

Status & tagging log