Merge "vector: Restore gray search input placeholder"
[lhc/web/wiklou.git] / includes / installer / Installer.php
index 1044f18..2f45005 100644 (file)
@@ -46,7 +46,6 @@ abstract class Installer {
         */
        protected $settings;
 
-
        /**
         * List of detected DBs, access using getCompiledDBs().
         *
@@ -159,7 +158,6 @@ abstract class Installer {
                'wgImageMagickConvertCommand',
                'wgGitBin',
                'IP',
-               'wgServer',
                'wgScriptPath',
                'wgScriptExtension',
                'wgMetaNamespace',
@@ -304,7 +302,8 @@ abstract class Installer {
        /**
         * URL to mediawiki-announce subscription
         */
-       protected $mediaWikiAnnounceUrl = 'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce';
+       protected $mediaWikiAnnounceUrl =
+               'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce';
 
        /**
         * Supported language codes for Mailman
@@ -513,6 +512,7 @@ abstract class Installer {
                if ( file_exists( "$IP/AdminSettings.php" ) ) {
                        require "$IP/AdminSettings.php";
                }
+
                return get_defined_vars();
        }
 
@@ -639,6 +639,7 @@ abstract class Installer {
                        'ss_users' => 0,
                        'ss_images' => 0 ),
                        __METHOD__, 'IGNORE' );
+
                return Status::newGood();
        }
 
@@ -670,7 +671,7 @@ abstract class Installer {
 
                $databases = $this->getCompiledDBs();
 
-               $databases = array_flip ( $databases );
+               $databases = array_flip( $databases );
                foreach ( array_keys( $databases ) as $db ) {
                        $installer = $this->getDBInstaller( $db );
                        $status = $installer->checkPrerequisites();
@@ -684,9 +685,11 @@ abstract class Installer {
                $databases = array_flip( $databases );
                if ( !$databases ) {
                        $this->showError( 'config-no-db', $wgLang->commaList( $allNames ) );
+
                        // @todo FIXME: This only works for the web installer!
                        return false;
                }
+
                return true;
        }
 
@@ -707,8 +710,10 @@ abstract class Installer {
                $test = new PhpXmlBugTester();
                if ( !$test->ok ) {
                        $this->showError( 'config-brokenlibxml' );
+
                        return false;
                }
+
                return true;
        }
 
@@ -722,8 +727,10 @@ abstract class Installer {
                $test->execute();
                if ( !$test->ok ) {
                        $this->showError( 'config-using531', phpversion() );
+
                        return false;
                }
+
                return true;
        }
 
@@ -734,8 +741,10 @@ abstract class Installer {
        protected function envCheckMagicQuotes() {
                if ( wfIniGetBool( "magic_quotes_runtime" ) ) {
                        $this->showError( 'config-magic-quotes-runtime' );
+
                        return false;
                }
+
                return true;
        }
 
@@ -746,8 +755,10 @@ abstract class Installer {
        protected function envCheckMagicSybase() {
                if ( wfIniGetBool( 'magic_quotes_sybase' ) ) {
                        $this->showError( 'config-magic-quotes-sybase' );
+
                        return false;
                }
+
                return true;
        }
 
@@ -758,8 +769,10 @@ abstract class Installer {
        protected function envCheckMbstring() {
                if ( wfIniGetBool( 'mbstring.func_overload' ) ) {
                        $this->showError( 'config-mbstring' );
+
                        return false;
                }
+
                return true;
        }
 
@@ -770,8 +783,10 @@ abstract class Installer {
        protected function envCheckZE1() {
                if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) {
                        $this->showError( 'config-ze1' );
+
                        return false;
                }
+
                return true;
        }
 
@@ -784,6 +799,7 @@ abstract class Installer {
                        $this->setVar( '_SafeMode', true );
                        $this->showMessage( 'config-safe-mode' );
                }
+
                return true;
        }
 
@@ -794,8 +810,10 @@ abstract class Installer {
        protected function envCheckXML() {
                if ( !function_exists( "utf8_encode" ) ) {
                        $this->showError( 'config-xml-bad' );
+
                        return false;
                }
+
                return true;
        }
 
@@ -810,6 +828,7 @@ abstract class Installer {
        protected function envCheckPCRE() {
                if ( !function_exists( 'preg_match' ) ) {
                        $this->showError( 'config-pcre' );
+
                        return false;
                }
                wfSuppressWarnings();
@@ -822,8 +841,10 @@ abstract class Installer {
                wfRestoreWarnings();
                if ( $regexd != '--' || $regexprop != '--' ) {
                        $this->showError( 'config-pcre-no-utf8' );
+
                        return false;
                }
+
                return true;
        }
 
@@ -850,6 +871,7 @@ abstract class Installer {
                                $this->setVar( '_RaiseMemory', true );
                        }
                }
+
                return true;
        }
 
@@ -882,6 +904,7 @@ abstract class Installer {
                if ( self::apacheModulePresent( 'mod_security' ) ) {
                        $this->showMessage( 'config-mod-security' );
                }
+
                return true;
        }
 
@@ -901,6 +924,7 @@ abstract class Installer {
                        $this->setVar( 'wgDiff3', false );
                        $this->showMessage( 'config-diff3-bad' );
                }
+
                return true;
        }
 
@@ -917,13 +941,14 @@ abstract class Installer {
                if ( $convert ) {
                        $this->setVar( 'wgImageMagickConvertCommand', $convert );
                        $this->showMessage( 'config-imagemagick', $convert );
+
                        return true;
                } elseif ( function_exists( 'imagejpeg' ) ) {
                        $this->showMessage( 'config-gd' );
-
                } else {
                        $this->showMessage( 'config-no-scaling' );
                }
+
                return true;
        }
 
@@ -946,6 +971,7 @@ abstract class Installer {
                        $this->setVar( 'wgGitBin', false );
                        $this->showMessage( 'config-git-bad' );
                }
+
                return true;
        }
 
@@ -954,8 +980,11 @@ abstract class Installer {
         */
        protected function envCheckServer() {
                $server = $this->envGetDefaultServer();
-               $this->showMessage( 'config-using-server', $server );
-               $this->setVar( 'wgServer', $server );
+               if ( $server !== null ) {
+                       $this->showMessage( 'config-using-server', $server );
+                       $this->setVar( 'wgServer', $server );
+               }
+
                return true;
        }
 
@@ -974,7 +1003,12 @@ abstract class Installer {
                $IP = dirname( dirname( __DIR__ ) );
                $this->setVar( 'IP', $IP );
 
-               $this->showMessage( 'config-using-uri', $this->getVar( 'wgServer' ), $this->getVar( 'wgScriptPath' ) );
+               $this->showMessage(
+                       'config-using-uri',
+                       $this->getVar( 'wgServer' ),
+                       $this->getVar( 'wgScriptPath' )
+               );
+
                return true;
        }
 
@@ -990,6 +1024,7 @@ abstract class Installer {
                        $ext = 'php';
                }
                $this->setVar( 'wgScriptExtension', ".$ext" );
+
                return true;
        }
 
@@ -1035,6 +1070,7 @@ abstract class Installer {
                # Try the current value of LANG.
                if ( isset( $candidatesByLocale[getenv( 'LANG' )] ) ) {
                        $this->setVar( 'wgShellLocale', getenv( 'LANG' ) );
+
                        return true;
                }
 
@@ -1043,6 +1079,7 @@ abstract class Installer {
                foreach ( $commonLocales as $commonLocale ) {
                        if ( isset( $candidatesByLocale[$commonLocale] ) ) {
                                $this->setVar( 'wgShellLocale', $commonLocale );
+
                                return true;
                        }
                }
@@ -1053,6 +1090,7 @@ abstract class Installer {
                if ( isset( $candidatesByLang[$wikiLang] ) ) {
                        $m = reset( $candidatesByLang[$wikiLang] );
                        $this->setVar( 'wgShellLocale', $m[0] );
+
                        return true;
                }
 
@@ -1060,6 +1098,7 @@ abstract class Installer {
                if ( count( $candidatesByLocale ) ) {
                        $m = reset( $candidatesByLocale );
                        $this->setVar( 'wgShellLocale', $m[0] );
+
                        return true;
                }
 
@@ -1081,6 +1120,7 @@ abstract class Installer {
                if ( !$safe ) {
                        $this->showMessage( 'config-uploads-not-safe', $dir );
                }
+
                return true;
        }
 
@@ -1095,6 +1135,7 @@ abstract class Installer {
                        // Only warn if the value is below the sane 1024
                        $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength );
                }
+
                return true;
        }
 
@@ -1160,7 +1201,8 @@ abstract class Installer {
                        }
                }
 
-               // Uses messages 'config-unicode-using-php', 'config-unicode-using-utf8', 'config-unicode-using-intl'
+               // Uses messages 'config-unicode-using-php', 'config-unicode-using-utf8',
+               // 'config-unicode-using-intl'
                if ( $useNormalizer === 'php' ) {
                        $this->showMessage( 'config-unicode-pure-php-warning' );
                } else {
@@ -1177,8 +1219,10 @@ abstract class Installer {
        protected function envCheckCtype() {
                if ( !function_exists( 'ctype_digit' ) ) {
                        $this->showError( 'config-ctype' );
+
                        return false;
                }
+
                return true;
        }
 
@@ -1188,8 +1232,10 @@ abstract class Installer {
        protected function envCheckJSON() {
                if ( !function_exists( 'json_decode' ) ) {
                        $this->showError( 'config-json' );
+
                        return false;
                }
+
                return true;
        }
 
@@ -1218,8 +1264,8 @@ abstract class Installer {
         * @param string $path path to search
         * @param array $names of executable names
         * @param $versionInfo Boolean false or array with two members:
-        *               0 => Command to run for version check, with $1 for the full executable name
-        *               1 => String to compare the output with
+        *         0 => Command to run for version check, with $1 for the full executable name
+        *         1 => String to compare the output with
         *
         * If $versionInfo is not false, only executables with a version
         * matching $versionInfo[1] will be returned.
@@ -1248,6 +1294,7 @@ abstract class Installer {
                                }
                        }
                }
+
                return false;
        }
 
@@ -1265,6 +1312,7 @@ abstract class Installer {
                                return $exe;
                        }
                }
+
                return false;
        }
 
@@ -1298,8 +1346,7 @@ abstract class Installer {
 
                                try {
                                        $text = Http::get( $url . $file, array( 'timeout' => 3 ) );
-                               }
-                               catch ( MWException $e ) {
+                               } catch ( MWException $e ) {
                                        // Http::get throws with allow_url_fopen = false and no curl extension.
                                        $text = null;
                                }
@@ -1307,6 +1354,7 @@ abstract class Installer {
 
                                if ( $text == 'exec' ) {
                                        wfRestoreWarnings();
+
                                        return $ext;
                                }
                        }
@@ -1331,6 +1379,7 @@ abstract class Installer {
                ob_start();
                phpinfo( INFO_MODULES );
                $info = ob_get_clean();
+
                return strpos( $info, $moduleName ) !== false;
        }
 
@@ -1436,13 +1485,13 @@ abstract class Installer {
         */
        protected function getInstallSteps( DatabaseInstaller $installer ) {
                $coreInstallSteps = array(
-                       array( 'name' => 'database',   'callback' => array( $installer, 'setupDatabase' ) ),
-                       array( 'name' => 'tables',     'callback' => array( $installer, 'createTables' ) ),
-                       array( 'name' => 'interwiki',  'callback' => array( $installer, 'populateInterwikiTable' ) ),
-                       array( 'name' => 'stats',      'callback' => array( $this, 'populateSiteStats' ) ),
-                       array( 'name' => 'keys',       'callback' => array( $this, 'generateKeys' ) ),
-                       array( 'name' => 'sysop',      'callback' => array( $this, 'createSysop' ) ),
-                       array( 'name' => 'mainpage',   'callback' => array( $this, 'createMainpage' ) ),
+                       array( 'name' => 'database', 'callback' => array( $installer, 'setupDatabase' ) ),
+                       array( 'name' => 'tables', 'callback' => array( $installer, 'createTables' ) ),
+                       array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ),
+                       array( 'name' => 'stats', 'callback' => array( $this, 'populateSiteStats' ) ),
+                       array( 'name' => 'keys', 'callback' => array( $this, 'generateKeys' ) ),
+                       array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ),
+                       array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ),
                );
 
                // Build the array of install steps starting from the core install list,
@@ -1475,6 +1524,7 @@ abstract class Installer {
                                'callback' => array( $installer, 'createExtensionTables' )
                        );
                }
+
                return $this->installSteps;
        }
 
@@ -1511,6 +1561,7 @@ abstract class Installer {
                if ( $status->isOk() ) {
                        $this->setVar( '_InstallDone', true );
                }
+
                return $installResults;
        }
 
@@ -1524,6 +1575,7 @@ abstract class Installer {
                if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
                        $keys['wgUpgradeKey'] = 16;
                }
+
                return $this->doGenerateKeys( $keys );
        }
 
@@ -1645,10 +1697,11 @@ abstract class Installer {
                        );
 
                        $page->doEditContent( $content,
-                                       '',
-                                       EDIT_NEW,
-                                       false,
-                                       User::newFromName( 'MediaWiki default' ) );
+                               '',
+                               EDIT_NEW,
+                               false,
+                               User::newFromName( 'MediaWiki default' )
+                       );
                } catch ( MWException $e ) {
                        //using raw, because $wgShowExceptionDetails can not be set yet
                        $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
@@ -1684,6 +1737,11 @@ abstract class Installer {
 
                // Some of the environment checks make shell requests, remove limits
                $GLOBALS['wgMaxShellMemory'] = 0;
+
+               // Don't bother embedding images into generated CSS, which is not cached
+               $GLOBALS['wgResourceLoaderLESSFunctions']['embeddable'] = function( $frame, $less ) {
+                       return $less->toBool( false );
+               };
        }
 
        /**