Merge "(bug 36908) Language::isValidBuiltInCode passed an object"
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 18 May 2012 21:50:35 +0000 (21:50 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 18 May 2012 21:50:35 +0000 (21:50 +0000)
languages/Language.php

index b36732b..240b0d3 100644 (file)
@@ -245,6 +245,15 @@ class Language {
         * @return bool
         */
        public static function isValidBuiltInCode( $code ) {
+
+               if( !is_string($code) ) {
+                       $type = gettype( $code );
+                       if( $type === 'object' ) {
+                               $addmsg = " of class " . get_class( $code );
+                       }
+                       throw new MWException( __METHOD__ . " must be passed a string, $type given$addmsg" );
+               }
+
                return preg_match( '/^[a-z0-9-]+$/i', $code );
        }