From: Niklas Laxström Date: Mon, 22 Aug 2011 08:12:10 +0000 (+0000) Subject: Make the language recaching non-recursive and load the data directly. X-Git-Tag: 1.31.0-rc.0~28134 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=4fa97663e74ccf0660f891ade47c95f872169274;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/includes/LocalisationCache.php b/includes/LocalisationCache.php index b20db3298a..96b377592b 100644 --- a/includes/LocalisationCache.php +++ b/includes/LocalisationCache.php @@ -514,6 +514,7 @@ class LocalisationCache { foreach ( $data as $key => $value ) { $this->mergeItem( $key, $coreData[$key], $value ); } + } # Fill in the fallback if it's not there already @@ -532,17 +533,24 @@ class LocalisationCache { } # Load the fallback localisation item by item and merge it - foreach ( $coreData['fallbackSequence'] as $fallback ) { - $deps = array_merge( $deps, $this->getItem( $fallback, 'deps' ) ); + foreach ( $coreData['fallbackSequence'] as $fbCode ) { + + # Load the secondary localisation from the source file to + # avoid infinite cycles on cyclic fallbacks + $fbFilename = Language::getMessagesFileName( $fbCode ); + if ( !file_exists( $fbFilename ) ) continue; + + $deps[] = new FileDependency( $fbFilename ); + $fbData = $this->readPHPFile( $fbFilename, 'core' ); foreach ( self::$allKeys as $key ) { + if ( !isset( $fbData[$key] ) ) continue; if ( is_null( $coreData[$key] ) || $this->isMergeableKey( $key ) ) { - $fallbackValue = $this->getItem( $fallback, $key ); - $this->mergeItem( $key, $coreData[$key], $fallbackValue ); + $this->mergeItem( $key, $coreData[$key], $fbData[$key] ); } } } - } + $codeSequence = array_merge( array( $code ), $coreData['fallbackSequence'] ); # Load the extension localisations