Merge "Align "What's this" vertically"
[lhc/web/wiklou.git] / includes / installer / Installer.php
index d887a13..52be321 100644 (file)
@@ -134,6 +134,7 @@ abstract class Installer {
                'envCheckUploadsDirectory',
                'envCheckLibicu',
                'envCheckSuhosinMaxValueLength',
+               'envCheck64Bit',
        ];
 
        /**
@@ -216,7 +217,7 @@ abstract class Installer {
                '_UpgradeKeySupplied' => false,
                '_ExistingDBSettings' => false,
 
-               // $wgLogo is probably wrong (bug 48084); set something that will work.
+               // $wgLogo is probably wrong (T50084); set something that will work.
                // Single quotes work fine here, as LocalSettingsGenerator outputs this unescaped.
                'wgLogo' => '$wgResourceBasePath/resources/assets/wiki.png',
                'wgAuthenticationTokenVersion' => 1,
@@ -384,7 +385,7 @@ abstract class Installer {
 
                // make sure we use the installer config as the main config
                $configRegistry = $baseConfig->get( 'ConfigRegistry' );
-               $configRegistry['main'] = function() use ( $installerConfig ) {
+               $configRegistry['main'] = function () use ( $installerConfig ) {
                        return $installerConfig;
                };
 
@@ -446,6 +447,9 @@ 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' ) );
        }
 
        /**
@@ -674,7 +678,7 @@ abstract class Installer {
                try {
                        $out = $wgParser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart );
                        $html = $out->getText();
-               } catch ( DBAccessError $e ) {
+               } catch ( MediaWiki\Services\ServiceDisabledException $e ) {
                        $html = '<!--DB access attempted during parse-->  ' . htmlspecialchars( $text );
 
                        if ( !empty( $this->debug ) ) {
@@ -722,6 +726,7 @@ abstract class Installer {
                                'ss_good_articles' => 0,
                                'ss_total_pages' => 0,
                                'ss_users' => 0,
+                               'ss_active_users' => 0,
                                'ss_images' => 0
                        ],
                        __METHOD__, 'IGNORE'
@@ -1013,7 +1018,7 @@ abstract class Installer {
                }
 
                # Try the most common ones.
-               $commonLocales = [ 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' ];
+               $commonLocales = [ 'C.UTF-8', 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' ];
                foreach ( $commonLocales as $commonLocale ) {
                        if ( isset( $candidatesByLocale[$commonLocale] ) ) {
                                $this->setVar( 'wgShellLocale', $commonLocale );
@@ -1077,6 +1082,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
@@ -1336,7 +1355,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 ) {
@@ -1349,7 +1368,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 = [];
@@ -1358,11 +1377,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;
        }
@@ -1431,7 +1458,7 @@ abstract class Installer {
                        );
                }
                // Unset everyone else's hooks. Lord knows what someone might be doing
-               // in ParserFirstCallInit (see bug 27171)
+               // in ParserFirstCallInit (see T29171)
                $GLOBALS['wgHooks'] = [ 'LoadExtensionSchemaUpdates' => $hooksWeWant ];
 
                return Status::newGood();
@@ -1656,8 +1683,13 @@ abstract class Installer {
         */
        protected function createMainpage( DatabaseInstaller $installer ) {
                $status = Status::newGood();
+               $title = Title::newMainPage();
+               if ( $title->exists() ) {
+                       $status->warning( 'config-install-mainpage-exists' );
+                       return $status;
+               }
                try {
-                       $page = WikiPage::factory( Title::newMainPage() );
+                       $page = WikiPage::factory( $title );
                        $content = new WikitextContent(
                                wfMessage( 'mainpagetext' )->inContentLanguage()->text() . "\n\n" .
                                wfMessage( 'mainpagedocfooter' )->inContentLanguage()->text()