Page MenuHomePhabricator

Multiple fallbacks kills server
Closed, InvalidPublic

Description

If there are multiple fallbacks, which otherwise seems to be supported, then localization of language names dies.

In the current setup nn is used as fallback for nb, and nb for nn. That means there is a loop in the fallbacks, if one fallback is merged into another. I guess there should be some laundering of fallbacks to avoid loops.

There is a few variations over where the server dies, but line 32 in LanguageNames.body.php seems to be interesting

public static function getNames( $code, $fbMethod = self::FALLBACK_NATIVE, $list = self::LIST_MW ) {

		$xx = self::loadLanguage( $code );
		$native = Language::getLanguageNames( $list === self::LIST_MW_SUPPORTED );

		if ( $fbMethod === self::FALLBACK_NATIVE ) {
			$names = array_merge( $native, $xx );
		} elseif ( $fbMethod === self::FALLBACK_NORMAL ) {
			$fallback = $code;
			$fb = $xx;
			while ( $fallback = Language::getFallbackFor( $fallback ) ) {
				/* Over write the things in fallback with what we have already */

32 >>>> $fb = array_merge( self::loadLanguage( $fallback ), $fb );

			}

			/* Add native names for codes that are not in cldr */
			$names = array_merge( $native, $fb );

			/* As a last resort, try the native name in Names.php */
			if ( !isset( $names[$code] ) && isset( $native[$code] ) ) {
				$names[$code] = $native[$code];
			}
		} else {
			throw new MWException( "Invalid value for 2:\$fallback in ".__METHOD__ );
		}

		switch ( $list ) {
			case self::LIST_MW:
			case self::LIST_MW_SUPPORTED:
				/* Remove entries that are not in fb */
				$names = array_intersect_key( $names, $native );
				/* And fall to the return */
			case self::LIST_MW_AND_CLDR:
				return $names;
			default:
				throw new MWException( "Invalid value for 3:\$list in ".__METHOD__ );
		}

}

Another place seems to be line number 103

public static function coreHook( &$names, $code ) {
103 >>> $names += self::getNames( $code, self::FALLBACK_NORMAL, self::LIST_MW_AND_CLDR );

		return true;

}

Note that the real problem could be somewhere else as the server is killed because of a timeout.

Note that this bug could be important for the Wikibase extension, if we choose to use the existing fallback chains for our global language fallbacks.


Version: unspecified
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=36430

Details

Reference
bz38399

Related Objects

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 1:11 AM
bzimport set Reference to bz38399.
bzimport added a subscriber: Unknown Object (MLST).

Use (later) version of the CLDR extension that is compatible with your version of MediaWiki. I'm sorry for the inconvenience for lack of proper dependency tracking.

Updated to bleeding edge for dev site and the bug was gone. Thanks!