fix E_NOTICE on r53720 and r53721.
authorShinjiman <shinjiman@users.mediawiki.org>
Fri, 24 Jul 2009 18:35:09 +0000 (18:35 +0000)
committerShinjiman <shinjiman@users.mediawiki.org>
Fri, 24 Jul 2009 18:35:09 +0000 (18:35 +0000)
includes/GlobalFunctions.php

index 48638bd..bf3c33f 100644 (file)
@@ -3195,15 +3195,20 @@ function wfObjectToArray( $object, $recursive = true ) {
 function wfBCP47( $code ) {
        $codeSegment = explode( '-', $code );
        foreach ( $codeSegment as $segNo => $seg ) {
-               // ISO 3166 country code
-               if ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) )
-                       $codeBCP[$segNo] = strtoupper ( $seg );
-               // ISO 15924 script code
-               else if ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) )
-                       $codeBCP[$segNo] = ucfirst( $seg );
-               // Keep casing for other cases
-               else
+               if ( count( $codeSegment ) > 0 ) {
+                       // ISO 3166 country code
+                       if ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) )
+                               $codeBCP[$segNo] = strtoupper ( $seg );
+                       // ISO 15924 script code
+                       else if ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) )
+                               $codeBCP[$segNo] = ucfirst( $seg );
+                       else
+                       // Keep casing for other cases
+                               $codeBCP[$segNo] = $seg;
+               } else {
+               // Keep casing for single segment
                        $codeBCP[$segNo] = $seg;
+               }
        }
        $langCode = implode ( '-' , $codeBCP );
        return $langCode;