Throw exception on wrong type in Language::isValidCode( $code )
authorFomafix <fomafix@googlemail.com>
Wed, 27 Jun 2018 10:16:26 +0000 (12:16 +0200)
committerFomafix <fomafix@googlemail.com>
Tue, 12 Mar 2019 15:40:31 +0000 (16:40 +0100)
This prevents that Language::isValidCode( null ) returns true.

Depends-On: I38d8358469903afb15331212206635283cedcd46
Change-Id: I5dc5bd45d648a548dfd27aaa1b3c29a2e99f0e8b

languages/Language.php

index 5ac2882..aaaf2a2 100644 (file)
@@ -386,6 +386,7 @@ class Language {
         */
        public static function isValidCode( $code ) {
                static $cache = [];
+               Assert::parameterType( 'string', $code, '$code' );
                if ( !isset( $cache[$code] ) ) {
                        // People think language codes are html safe, so enforce it.
                        // Ideally we should only allow a-zA-Z0-9-