User "Nikerabbit" posted a comment on MediaWiki.r95646.

Full URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95646#c21574
Commit summary:

In Language::isValidBuiltInCode(), reject the empty string per Nikerabbit's 
request on CR r82927. I'm not sure what the reason for the request was, but I 
suppose an empty language code could result in the base Language class being 
used, which could be problematic for some caller. It doesn't do any harm to 
reject it here.

Comment:

The reason is my new fallback code. This function sometimes gets called with an 
empty string. That resulted in this exception:
<pre>
mediawiki-bw_: /w/i.php?title=MediaWiki:Sitenotice&action=edit
Exception from line 909 of /www/w/includes/LocalisationCache.php: 
LCStore_CDB::getFileName: Invalid language ""
</pre>

I began thinking why I had to write a, while I was excepting b to be enough.
<pre>
a: if ( $code === '' || $code === 'en' || !Language::isValidBuiltInCode( $code 
) ) {
b: if ( $code === 'en' || !Language::isValidBuiltInCode( $code ) ) {
</pre>

<pre>
        static function getFallbacksFor( $code ) {
                if ( $code === 'en' ) {
                        return array();
                } else {
                        $v = self::getLocalisationCache()->getItem( $code, 
'fallback' );
                        $v = array_map( 'trim', explode( ',', $v ) );
                        if ( $v[count( $v ) - 1] !== 'en' ) {
                                $v[] = 'en';
                        }
                        return $v;
                }
        }
</pre>
(You can see that function is not yet fixed to validate the code.)

_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview

Reply via email to