Check minimum database server version when running update.php
[lhc/web/wiklou.git] / includes / installer / Installer.php
index 168d7ed..012b477 100644 (file)
@@ -134,6 +134,7 @@ abstract class Installer {
                'envCheckUploadsDirectory',
                'envCheckLibicu',
                'envCheckSuhosinMaxValueLength',
+               'envCheck64Bit',
        ];
 
        /**
@@ -446,6 +447,7 @@ abstract class Installer {
                $this->parserTitle = Title::newFromText( 'Installer' );
                $this->parserOptions = new ParserOptions( $wgUser ); // language will be wrong :(
                $this->parserOptions->setEditSection( false );
+               $this->parserOptions->setWrapOutputClass( false );
                // Don't try to access DB before user language is initialised
                $this->setParserLanguage( Language::factory( 'en' ) );
        }
@@ -544,6 +546,17 @@ abstract class Installer {
                return $this->compiledDBs;
        }
 
+       /**
+        * Get the DatabaseInstaller class name for this type
+        *
+        * @param string $type database type ($wgDBtype)
+        * @return string Class name
+        * @since 1.30
+        */
+       public static function getDBInstallerClass( $type ) {
+               return ucfirst( $type ) . 'Installer';
+       }
+
        /**
         * Get an instance of DatabaseInstaller for the specified DB type.
         *
@@ -559,7 +572,7 @@ abstract class Installer {
                $type = strtolower( $type );
 
                if ( !isset( $this->dbInstallers[$type] ) ) {
-                       $class = ucfirst( $type ) . 'Installer';
+                       $class = self::getDBInstallerClass( $type );
                        $this->dbInstallers[$type] = new $class( $this );
                }
 
@@ -1080,6 +1093,20 @@ abstract class Installer {
                return true;
        }
 
+       /**
+        * Checks if we're running on 64 bit or not. 32 bit is becoming increasingly
+        * hard to support, so let's at least warn people.
+        *
+        * @return bool
+        */
+       protected function envCheck64Bit() {
+               if ( PHP_INT_SIZE == 4 ) {
+                       $this->showMessage( 'config-using-32bit' );
+               }
+
+               return true;
+       }
+
        /**
         * Convert a hex string representing a Unicode code point to that code point.
         * @param string $c
@@ -1339,7 +1366,7 @@ abstract class Installer {
         * Reasonable values for $directory include 'extensions' (the default) and 'skins'.
         *
         * @param string $directory Directory to search in
-        * @return array
+        * @return array [ $extName => [ 'screenshots' => [ '...' ] ]
         */
        public function findExtensions( $directory = 'extensions' ) {
                if ( $this->getVar( 'IP' ) === null ) {
@@ -1352,7 +1379,7 @@ abstract class Installer {
                }
 
                // extensions -> extension.json, skins -> skin.json
-               $jsonFile = substr( $directory, 0, strlen( $directory ) -1 ) . '.json';
+               $jsonFile = substr( $directory, 0, strlen( $directory ) - 1 ) . '.json';
 
                $dh = opendir( $extDir );
                $exts = [];
@@ -1361,11 +1388,19 @@ abstract class Installer {
                                continue;
                        }
                        if ( file_exists( "$extDir/$file/$jsonFile" ) || file_exists( "$extDir/$file/$file.php" ) ) {
-                               $exts[] = $file;
+                               // Extension exists. Now see if there are screenshots
+                               $exts[$file] = [];
+                               if ( is_dir( "$extDir/$file/screenshots" ) ) {
+                                       $paths = glob( "$extDir/$file/screenshots/*.png" );
+                                       foreach ( $paths as $path ) {
+                                               $exts[$file]['screenshots'][] = str_replace( $extDir, "../$directory", $path );
+                                       }
+
+                               }
                        }
                }
                closedir( $dh );
-               natcasesort( $exts );
+               uksort( $exts, 'strnatcasecmp' );
 
                return $exts;
        }