https://bugzilla.wikimedia.org/show_bug.cgi?id=38399

       Web browser: ---
             Bug #: 38399
           Summary: Multiple fallbacks kills server
           Product: MediaWiki extensions
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: CLDR
        AssignedTo: wikibugs-l@lists.wikimedia.org
        ReportedBy: jeb...@gmail.com
                CC: niklas.laxst...@gmail.com
    Classification: Unclassified
   Mobile Platform: ---


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.

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to