phpcs: More require/include is not a function
[lhc/web/wiklou.git] / languages / Language.php
index b9201d7..c73ccd1 100644 (file)
@@ -32,7 +32,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
 
 # Read language names
 global $wgLanguageNames;
-require_once( __DIR__ . '/Names.php' );
+require_once __DIR__ . '/Names.php';
 
 if ( function_exists( 'mb_strtoupper' ) ) {
        mb_internal_encoding( 'UTF-8' );
@@ -326,13 +326,19 @@ class Language {
         * @return bool
         */
        public static function isValidCode( $code ) {
-               return
-                       // People think language codes are html safe, so enforce it.
-                       // Ideally we should only allow a-zA-Z0-9-
-                       // but, .+ and other chars are often used for {{int:}} hacks
-                       // see bugs 37564, 37587, 36938
+               static $cache = array();
+               if ( isset( $cache[$code] ) ) {
+                       return $cache[$code];
+               }
+               // People think language codes are html safe, so enforce it.
+               // Ideally we should only allow a-zA-Z0-9-
+               // but, .+ and other chars are often used for {{int:}} hacks
+               // see bugs 37564, 37587, 36938
+               $cache[$code] =
                        strcspn( $code, ":/\\\000&<>'\"" ) === strlen( $code )
                        && !preg_match( Title::getTitleInvalidRegex(), $code );
+
+               return $cache[$code];
        }
 
        /**
@@ -372,7 +378,7 @@ class Language {
                static $coreLanguageNames;
 
                if ( $coreLanguageNames === null ) {
-                       include( MWInit::compiledPath( 'languages/Names.php' ) );
+                       include MWInit::compiledPath( 'languages/Names.php' );
                }
 
                if ( isset( $coreLanguageNames[$tag] )
@@ -408,10 +414,8 @@ class Language {
                        return;
                }
 
-               if ( !defined( 'MW_COMPILED' ) ) {
-                       if ( file_exists( "$IP/languages/classes/$class.php" ) ) {
-                               include_once( "$IP/languages/classes/$class.php" );
-                       }
+               if ( file_exists( "$IP/languages/classes/$class.php" ) ) {
+                       include_once "$IP/languages/classes/$class.php";
                }
        }
 
@@ -845,7 +849,7 @@ class Language {
                static $coreLanguageNames;
 
                if ( $coreLanguageNames === null ) {
-                       include( MWInit::compiledPath( 'languages/Names.php' ) );
+                       include MWInit::compiledPath( 'languages/Names.php' );
                }
 
                $names = array();