Fix for Bug #29628 - scriptpath Option of maintenance/install.php is ignored
[lhc/web/wiklou.git] / includes / installer / Installer.php
index e836780..dfc56e9 100644 (file)
  */
 abstract class Installer {
 
+       // This is the absolute minimum PHP version we can support
+       const MINIMUM_PHP_VERSION = '5.2.3';
+
        /**
-        * TODO: make protected?
-        *
         * @var array
         */
-       public $settings;
+       protected $settings;
 
        /**
         * Cached DB installer instances, access using getDBInstaller().
@@ -72,6 +73,7 @@ abstract class Installer {
                'postgres',
                'oracle',
                'sqlite',
+               'ibm_db2',
        );
 
        /**
@@ -97,14 +99,16 @@ abstract class Installer {
                'envCheckCache',
                'envCheckDiff3',
                'envCheckGraphics',
+               'envCheckServer',
                'envCheckPath',
                'envCheckExtension',
                'envCheckShellLocale',
                'envCheckUploadsDirectory',
-               'envCheckLibicu'
+               'envCheckLibicu',
+               'envCheckSuhosinMaxValueLength',
        );
 
-               /**
+       /**
         * MediaWiki configuration globals that will eventually be passed through
         * to LocalSettings.php. The names only are given here, the defaults
         * typically come from DefaultSettings.php.
@@ -128,6 +132,7 @@ abstract class Installer {
                'wgDiff3',
                'wgImageMagickConvertCommand',
                'IP',
+               'wgServer',
                'wgScriptPath',
                'wgScriptExtension',
                'wgMetaNamespace',
@@ -139,6 +144,7 @@ abstract class Installer {
                'wgUseInstantCommons',
                'wgUpgradeKey',
                'wgDefaultSkin',
+               'wgResourceLoaderMaxQueryLength',
        );
 
        /**
@@ -157,7 +163,6 @@ abstract class Installer {
                '_UpgradeDone' => false,
                '_InstallDone' => false,
                '_Caches' => array(),
-               '_InstallUser' => 'root',
                '_InstallPassword' => '',
                '_SameAccount' => true,
                '_CreateDBAccount' => false,
@@ -234,6 +239,10 @@ abstract class Installer {
         * @var array
         */
        public $licenses = array(
+               'cc-by' => array(
+                       'url' => 'http://creativecommons.org/licenses/by/3.0/',
+                       'icon' => '{$wgStylePath}/common/images/cc-by.png',
+               ),
                'cc-by-sa' => array(
                        'url' => 'http://creativecommons.org/licenses/by-sa/3.0/',
                        'icon' => '{$wgStylePath}/common/images/cc-by-sa.png',
@@ -242,15 +251,15 @@ abstract class Installer {
                        'url' => 'http://creativecommons.org/licenses/by-nc-sa/3.0/',
                        'icon' => '{$wgStylePath}/common/images/cc-by-nc-sa.png',
                ),
+               'cc-0' => array(
+                       'url' => 'https://creativecommons.org/publicdomain/zero/1.0/',
+                       'icon' => '{$wgStylePath}/common/images/cc-0.png',
+               ),
                'pd' => array(
-                       'url' => 'http://creativecommons.org/licenses/publicdomain/',
+                       'url' => '',
                        'icon' => '{$wgStylePath}/common/images/public-domain.png',
                ),
-               'gfdl-old' => array(
-                       'url' => 'http://www.gnu.org/licenses/old-licenses/fdl-1.2.html',
-                       'icon' => '{$wgStylePath}/common/images/gnu-fdl.png',
-               ),
-               'gfdl-current' => array(
+               'gfdl' => array(
                        'url' => 'http://www.gnu.org/copyleft/fdl.html',
                        'icon' => '{$wgStylePath}/common/images/gnu-fdl.png',
                ),
@@ -289,6 +298,11 @@ abstract class Installer {
         */
        public abstract function showMessage( $msg /*, ... */ );
 
+       /**
+        * Same as showMessage(), but for displaying errors
+        */
+       public abstract function showError( $msg /*, ... */ );
+
        /**
         * Show a message to the installing user by using a Status object
         * @param $status Status
@@ -299,7 +313,7 @@ abstract class Installer {
         * Constructor, always call this from child classes.
         */
        public function __construct() {
-               global $wgExtensionMessagesFiles, $wgUser, $wgHooks;
+               global $wgExtensionMessagesFiles, $wgUser;
 
                // Disable the i18n cache and LoadBalancer
                Language::getLocalisationCache()->disableBackend();
@@ -312,9 +326,6 @@ abstract class Installer {
                // Having a user with id = 0 safeguards us from DB access via User::loadOptions().
                $wgUser = User::newFromId( 0 );
 
-               // Set our custom <doclink> hook.
-               $wgHooks['ParserFirstCallInit'][] = array( $this, 'registerDocLink' );
-
                $this->settings = $this->internalDefaults;
 
                foreach ( $this->defaultVarNames as $var ) {
@@ -346,6 +357,8 @@ abstract class Installer {
 
        /**
         * Get a list of known DB types.
+        *
+        * @return array
         */
        public static function getDBTypes() {
                return self::$dbTypes;
@@ -365,14 +378,21 @@ abstract class Installer {
         * @return Status
         */
        public function doEnvironmentChecks() {
-               $this->showMessage( 'config-env-php', phpversion() );
-
-               $good = true;
+               $phpVersion = phpversion();
+               if( version_compare( $phpVersion, self::MINIMUM_PHP_VERSION, '>=' ) ) {
+                       $this->showMessage( 'config-env-php', $phpVersion );
+                       $good = true;
+               } else {
+                       $this->showMessage( 'config-env-php-toolow', $phpVersion, self::MINIMUM_PHP_VERSION );
+                       $good = false;
+               }
 
-               foreach ( $this->envChecks as $check ) {
-                       $status = $this->$check();
-                       if ( $status === false ) {
-                               $good = false;
+               if( $good ) {
+                       foreach ( $this->envChecks as $check ) {
+                               $status = $this->$check();
+                               if ( $status === false ) {
+                                       $good = false;
+                               }
                        }
                }
 
@@ -437,7 +457,7 @@ abstract class Installer {
         *
         * @return Array
         */
-       public function getExistingLocalSettings() {
+       public static function getExistingLocalSettings() {
                global $IP;
 
                wfSuppressWarnings();
@@ -487,7 +507,7 @@ abstract class Installer {
         * On POSIX systems return the primary group of the webserver we're running under.
         * On other systems just returns null.
         *
-        * This is used to advice the user that he should chgrp his config/data/images directory as the
+        * This is used to advice the user that he should chgrp his mw-config/data/images directory as the
         * webserver user before he can install.
         *
         * Public because SqliteInstaller needs it, and doesn't subclass Installer.
@@ -542,6 +562,9 @@ abstract class Installer {
                return $html;
        }
 
+       /**
+        * @return ParserOptions
+        */
        public function getParserOptions() {
                return $this->parserOptions;
        }
@@ -555,6 +578,32 @@ abstract class Installer {
                $this->parserOptions->setExternalLinkTarget( $wgExternalLinkTarget );
        }
 
+       /**
+        * Install step which adds a row to the site_stats table with appropriate
+        * initial values.
+        *
+        * @param $installer DatabaseInstaller
+        *
+        * @return Status
+        */
+       public function populateSiteStats( DatabaseInstaller $installer ) {
+               $status = $installer->getConnection();
+               if ( !$status->isOK() ) {
+                       return $status;
+               }
+               $status->value->insert( 'site_stats', array(
+                       'ss_row_id' => 1,
+                       'ss_total_views' => 0,
+                       'ss_total_edits' => 0,
+                       'ss_good_articles' => 0,
+                       'ss_total_pages' => 0,
+                       'ss_users' => 0,
+                       'ss_admins' => 0,
+                       'ss_images' => 0 ),
+                       __METHOD__, 'IGNORE' );
+               return Status::newGood();
+       }
+
        /**
         * Exports all wg* variables stored by the installer into global scope.
         */
@@ -573,35 +622,27 @@ abstract class Installer {
                global $wgLang;
 
                $compiledDBs = array();
-               $goodNames = array();
                $allNames = array();
 
                foreach ( self::getDBTypes() as $name ) {
-                       $db = $this->getDBInstaller( $name );
-                       $readableName = wfMsg( 'config-type-' . $name );
-
-                       if ( $db->isCompiled() ) {
+                       if ( $this->getDBInstaller( $name )->isCompiled() ) {
                                $compiledDBs[] = $name;
-                               $goodNames[] = $readableName;
                        }
-
-                       $allNames[] = $readableName;
+                       $allNames[] = wfMsg( 'config-type-' . $name );
                }
 
                $this->setVar( '_CompiledDBs', $compiledDBs );
 
                if ( !$compiledDBs ) {
-                       $this->showMessage( 'config-no-db' );
-                       // FIXME: this only works for the web installer!
-                       $this->showHelpBox( 'config-no-db-help', $wgLang->commaList( $allNames ) );
+                       $this->showError( 'config-no-db', $wgLang->commaList( $allNames ) );
+                       // @todo FIXME: This only works for the web installer!
                        return false;
                }
 
                // Check for FTS3 full-text search module
                $sqlite = $this->getDBInstaller( 'sqlite' );
                if ( $sqlite->isCompiled() ) {
-                       $db = new DatabaseSqliteStandalone( ':memory:' );
-                       if( $db->getFulltextSearchModule() != 'FTS3' ) {
+                       if( DatabaseSqlite::getFulltextSearchModule() != 'FTS3' ) {
                                $this->showMessage( 'config-no-fts3' );
                        }
                }
@@ -622,7 +663,7 @@ abstract class Installer {
        protected function envCheckBrokenXML() {
                $test = new PhpXmlBugTester();
                if ( !$test->ok ) {
-                       $this->showMessage( 'config-brokenlibxml' );
+                       $this->showError( 'config-brokenlibxml' );
                        return false;
                }
        }
@@ -635,7 +676,7 @@ abstract class Installer {
                $test = new PhpRefCallBugTester;
                $test->execute();
                if ( !$test->ok ) {
-                       $this->showMessage( 'config-using531' );
+                       $this->showError( 'config-using531', phpversion() );
                        return false;
                }
        }
@@ -645,7 +686,7 @@ abstract class Installer {
         */
        protected function envCheckMagicQuotes() {
                if( wfIniGetBool( "magic_quotes_runtime" ) ) {
-                       $this->showMessage( 'config-magic-quotes-runtime' );
+                       $this->showError( 'config-magic-quotes-runtime' );
                        return false;
                }
        }
@@ -655,7 +696,7 @@ abstract class Installer {
         */
        protected function envCheckMagicSybase() {
                if ( wfIniGetBool( 'magic_quotes_sybase' ) ) {
-                       $this->showMessage( 'config-magic-quotes-sybase' );
+                       $this->showError( 'config-magic-quotes-sybase' );
                        return false;
                }
        }
@@ -665,7 +706,7 @@ abstract class Installer {
         */
        protected function envCheckMbstring() {
                if ( wfIniGetBool( 'mbstring.func_overload' ) ) {
-                       $this->showMessage( 'config-mbstring' );
+                       $this->showError( 'config-mbstring' );
                        return false;
                }
        }
@@ -675,7 +716,7 @@ abstract class Installer {
         */
        protected function envCheckZE1() {
                if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) {
-                       $this->showMessage( 'config-ze1' );
+                       $this->showError( 'config-ze1' );
                        return false;
                }
        }
@@ -695,7 +736,7 @@ abstract class Installer {
         */
        protected function envCheckXML() {
                if ( !function_exists( "utf8_encode" ) ) {
-                       $this->showMessage( 'config-xml-bad' );
+                       $this->showError( 'config-xml-bad' );
                        return false;
                }
        }
@@ -705,14 +746,14 @@ abstract class Installer {
         */
        protected function envCheckPCRE() {
                if ( !function_exists( 'preg_match' ) ) {
-                       $this->showMessage( 'config-pcre' );
+                       $this->showError( 'config-pcre' );
                        return false;
                }
                wfSuppressWarnings();
-               $regexd = preg_replace( '/[\x{0400}-\x{04FF}]/u', '', '-АБВГД-' );
+               $regexd = preg_replace( '/[\x{0430}-\x{04FF}]/iu', '', '-АБВГД-' );
                wfRestoreWarnings();
                if ( $regexd != '--' ) {
-                       $this->showMessage( 'config-pcre-no-utf8' );
+                       $this->showError( 'config-pcre-no-utf8' );
                        return false;
                }
        }
@@ -727,11 +768,7 @@ abstract class Installer {
                        return true;
                }
 
-               $n = intval( $limit );
-
-               if( preg_match( '/^([0-9]+)[Mm]$/', trim( $limit ), $m ) ) {
-                       $n = intval( $m[1] * ( 1024 * 1024 ) );
-               }
+               $n = wfShorthandToInteger( $limit );
 
                if( $n < $this->minMemorySize * 1024 * 1024 ) {
                        $newLimit = "{$this->minMemorySize}M";
@@ -789,6 +826,7 @@ abstract class Installer {
                $names = array( wfIsWindows() ? 'convert.exe' : 'convert' );
                $convert = self::locateExecutableInDefaultPaths( $names, array( '$1 -version', 'ImageMagick' ) );
 
+               $this->setVar( 'wgImageMagickConvertCommand', '' );
                if ( $convert ) {
                        $this->setVar( 'wgImageMagickConvertCommand', $convert );
                        $this->showMessage( 'config-imagemagick', $convert );
@@ -797,10 +835,19 @@ abstract class Installer {
                        $this->showMessage( 'config-gd' );
                        return true;
                } else {
-                       $this->showMessage( 'no-scaling' );
+                       $this->showMessage( 'config-no-scaling' );
                }
        }
 
+       /**
+        * Environment check for the server hostname.
+        */
+       protected function envCheckServer() {
+               $server = WebRequest::detectServer();
+               $this->showMessage( 'config-using-server', $server );
+               $this->setVar( 'wgServer', $server );
+       }
+
        /**
         * Environment check for setting $IP and $wgScriptPath.
         */
@@ -813,19 +860,20 @@ abstract class Installer {
                // PHP_SELF isn't available sometimes, such as when PHP is CGI but
                // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
                // to get the path to the current script... hopefully it's reliable. SIGH
-               if ( !empty( $_SERVER['PHP_SELF'] ) ) {
+               if ( $this->getVar( 'wgScriptPath' ) ) {
+                       // Some kind soul has set it for us already (e.g. debconf)
+                       return true;
+               } elseif ( !empty( $_SERVER['PHP_SELF'] ) ) {
                        $path = $_SERVER['PHP_SELF'];
                } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
                        $path = $_SERVER['SCRIPT_NAME'];
-               } elseif ( $this->getVar( 'wgScriptPath' ) ) {
-                       // Some kind soul has set it for us already (e.g. debconf)
                        return true;
                } else {
-                       $this->showMessage( 'config-no-uri' );
+                       $this->showError( 'config-no-uri' );
                        return false;
                }
 
-               $uri = preg_replace( '{^(.*)/config.*$}', '$1', $path );
+               $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
                $this->setVar( 'wgScriptPath', $uri );
        }
 
@@ -833,7 +881,7 @@ abstract class Installer {
         * Environment check for setting the preferred PHP file extension.
         */
        protected function envCheckExtension() {
-               // FIXME: detect this properly
+               // @todo FIXME: Detect this properly
                if ( defined( 'MW_INSTALL_PHP5_EXT' ) ) {
                        $ext = 'php5';
                } else {
@@ -919,10 +967,10 @@ abstract class Installer {
         * TODO: document
         */
        protected function envCheckUploadsDirectory() {
-               global $IP, $wgServer;
+               global $IP;
 
                $dir = $IP . '/images/';
-               $url = $wgServer . $this->getVar( 'wgScriptPath' ) . '/images/';
+               $url = $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/images/';
                $safe = !$this->dirIsExecutable( $dir, $url );
 
                if ( $safe ) {
@@ -932,6 +980,21 @@ abstract class Installer {
                }
        }
 
+       /**
+        * Checks if suhosin.get.max_value_length is set, and if so, sets
+        * $wgResourceLoaderMaxQueryLength to that value in the generated
+        * LocalSettings file
+        */
+       protected function envCheckSuhosinMaxValueLength() {
+               $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
+               if ( $maxValueLength > 0 ) {
+                       $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength );
+               } else {
+                       $maxValueLength = -1;
+               }
+               $this->setVar( 'wgResourceLoaderMaxQueryLength', $maxValueLength );
+       }
+
        /**
         * Convert a hex string representing a Unicode code point to that code point.
         * @param $c String
@@ -941,12 +1004,12 @@ abstract class Installer {
                $c = hexdec($c);
                if ($c <= 0x7F) {
                        return chr($c);
-               } else if ($c <= 0x7FF) {
+               } elseif ($c <= 0x7FF) {
                        return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
-               } else if ($c <= 0xFFFF) {
+               } elseif ($c <= 0xFFFF) {
                        return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
                                . chr(0x80 | $c & 0x3F);
-               } else if ($c <= 0x10FFFF) {
+               } elseif ($c <= 0x10FFFF) {
                        return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
                                . chr(0x80 | $c >> 6 & 0x3F)
                                . chr(0x80 | $c & 0x3F);
@@ -1098,7 +1161,13 @@ abstract class Installer {
                                        break;
                                }
 
-                               $text = Http::get( $url . $file );
+                               try {
+                                       $text = Http::get( $url . $file, array( 'timeout' => 3 ) );
+                               }
+                               catch( MWException $e ) {
+                                       // Http::get throws with allow_url_fopen = false and no curl extension.
+                                       $text = null;
+                               }
                                unlink( $dir . $file );
 
                                if ( $text == 'exec' ) {
@@ -1113,36 +1182,16 @@ abstract class Installer {
                return false;
        }
 
-       /**
-        * Register tag hook below.
-        *
-        * @todo Move this to WebInstaller with the two things below?
-        *
-        * @param $parser Parser
-        */
-       public function registerDocLink( Parser &$parser ) {
-               $parser->setHook( 'doclink', array( $this, 'docLink' ) );
-               return true;
-       }
-
        /**
         * ParserOptions are constructed before we determined the language, so fix it
+        *
+        * @param $lang Language
         */
        public function setParserLanguage( $lang ) {
                $this->parserOptions->setTargetLanguage( $lang );
                $this->parserOptions->setUserLang( $lang->getCode() );
        }
 
-       /**
-        * Extension tag hook for a documentation link.
-        */
-       public function docLink( $linkText, $attribs, $parser ) {
-               $url = $this->getDocUrl( $attribs['href'] );
-               return '<a href="' . htmlspecialchars( $url ) . '">' .
-                       htmlspecialchars( $linkText ) .
-                       '</a>';
-       }
-
        /**
         * Overridden by WebInstaller to provide lastPage parameters.
         */
@@ -1162,11 +1211,14 @@ abstract class Installer {
                }
 
                $exts = array();
-               $dir = $this->getVar( 'IP' ) . '/extensions';
-               $dh = opendir( $dir );
+               $extDir = $this->getVar( 'IP' ) . '/extensions';
+               $dh = opendir( $extDir );
 
                while ( ( $file = readdir( $dh ) ) !== false ) {
-                       if( file_exists( "$dir/$file/$file.php" ) ) {
+                       if( !is_dir( "$extDir/$file" ) ) {
+                               continue;
+                       }
+                       if( file_exists( "$extDir/$file/$file.php" ) ) {
                                $exts[] = $file;
                        }
                }
@@ -1180,13 +1232,34 @@ abstract class Installer {
         * @return Status
         */
        protected function includeExtensions() {
+               global $IP;
                $exts = $this->getVar( '_Extensions' );
-               $path = $this->getVar( 'IP' ) . '/extensions';
+               $IP = $this->getVar( 'IP' );
+
+               /**
+                * We need to include DefaultSettings before including extensions to avoid
+                * warnings about unset variables. However, the only thing we really
+                * want here is $wgHooks['LoadExtensionSchemaUpdates']. This won't work
+                * if the extension has hidden hook registration in $wgExtensionFunctions,
+                * but we're not opening that can of worms
+                * @see https://bugzilla.wikimedia.org/show_bug.cgi?id=26857
+                */
+               global $wgAutoloadClasses;
+               $wgAutoloadClasses = array();
+
+               require( "$IP/includes/DefaultSettings.php" );
 
                foreach( $exts as $e ) {
-                       require( "$path/$e/$e.php" );
+                       require_once( "$IP/extensions/$e/$e.php" );
                }
 
+               $hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?
+                       $wgHooks['LoadExtensionSchemaUpdates'] : array();
+
+               // Unset everyone else's hooks. Lord knows what someone might be doing
+               // in ParserFirstCallInit (see bug 27171)
+               $GLOBALS['wgHooks'] = array( 'LoadExtensionSchemaUpdates' => $hooksWeWant );
+
                return Status::newGood();
        }
 
@@ -1202,13 +1275,13 @@ abstract class Installer {
         * @param $installer DatabaseInstaller so we can make callbacks
         * @return array
         */
-       protected function getInstallSteps( DatabaseInstaller &$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' => 'secretkey',  'callback' => array( $this, 'generateSecretKey' ) ),
-                       array( 'name' => 'upgradekey', 'callback' => array( $this, 'generateUpgradeKey' ) ),
+                       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' ) ),
                );
@@ -1238,6 +1311,10 @@ abstract class Installer {
                        array_unshift( $this->installSteps,
                                array( 'name' => 'extensions', 'callback' => array( $this, 'includeExtensions' ) )
                        );
+                       $this->installSteps[] = array(
+                               'name' => 'extension-tables',
+                               'callback' => array( $installer, 'createExtensionTables' )
+                       );
                }
                return $this->installSteps;
        }
@@ -1245,8 +1322,8 @@ abstract class Installer {
        /**
         * Actually perform the installation.
         *
-        * @param $startCB A callback array for the beginning of each step
-        * @param $endCB A callback array for the end of each step
+        * @param $startCB Array A callback array for the beginning of each step
+        * @param $endCB Array A callback array for the end of each step
         *
         * @return Array of Status objects
         */
@@ -1260,10 +1337,10 @@ abstract class Installer {
                        call_user_func_array( $startCB, array( $name ) );
 
                        // Perform the callback step
-                       $status = call_user_func_array( $stepObj['callback'], array( &$installer ) );
+                       $status = call_user_func( $stepObj['callback'], $installer );
 
                        // Output and save the results
-                       call_user_func_array( $endCB, array( $name, $status ) );
+                       call_user_func( $endCB, $name, $status );
                        $installResults[$name] = $status;
 
                        // If we've hit some sort of fatal, we need to bail.
@@ -1284,57 +1361,54 @@ abstract class Installer {
         *
         * @return Status
         */
-       protected function generateSecretKey() {
-               return $this->generateSecret( 'wgSecretKey' );
+       public function generateKeys() {
+               $keys = array( 'wgSecretKey' => 64 );
+               if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
+                       $keys['wgUpgradeKey'] = 16;
+               }
+               return $this->doGenerateKeys( $keys );
        }
 
        /**
-        * Generate a secret value for a variable using either
-        * /dev/urandom or mt_rand() Produce a warning in the later case.
+        * Generate a secret value for variables using either
+        * /dev/urandom or mt_rand(). Produce a warning in the later case.
         *
+        * @param $keys Array
         * @return Status
         */
-       protected function generateSecret( $secretName, $length = 64 ) {
-               if ( wfIsWindows() ) {
-                       $file = null;
-               } else {
-                       wfSuppressWarnings();
-                       $file = fopen( "/dev/urandom", "r" );
-                       wfRestoreWarnings();
-               }
-
+       protected function doGenerateKeys( $keys ) {
                $status = Status::newGood();
 
-               if ( $file ) {
-                       $secretKey = bin2hex( fread( $file, $length / 2 ) );
-                       fclose( $file );
-               } else {
-                       $secretKey = '';
+               wfSuppressWarnings();
+               $file = fopen( "/dev/urandom", "r" );
+               wfRestoreWarnings();
 
-                       for ( $i = 0; $i < $length / 8; $i++ ) {
-                               $secretKey .= dechex( mt_rand( 0, 0x7fffffff ) );
+               foreach ( $keys as $name => $length ) {
+                       if ( $file ) {
+                                       $secretKey = bin2hex( fread( $file, $length / 2 ) );
+                       } else {
+                               $secretKey = '';
+
+                               for ( $i = 0; $i < $length / 8; $i++ ) {
+                                       $secretKey .= dechex( mt_rand( 0, 0x7fffffff ) );
+                               }
                        }
 
-                       $status->warning( 'config-insecure-secret', '$' . $secretName );
+                       $this->setVar( $name, $secretKey );
                }
 
-               $this->setVar( $secretName, $secretKey );
+               if ( $file ) {
+                       fclose( $file );
+               } else {
+                       $names = array_keys ( $keys );
+                       $names = preg_replace( '/^(.*)$/', '\$$1', $names );
+                       global $wgLang;
+                       $status->warning( 'config-insecure-keys', $wgLang->listToText( $names ), count( $names ) );
+               }
 
                return $status;
        }
 
-       /**
-        * Generate a default $wgUpgradeKey. Will warn if we had to use
-        * mt_rand() instead of /dev/urandom
-        *
-        * @return Status
-        */
-       public function generateUpgradeKey() {
-               if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
-                       return $this->generateSecret( 'wgUpgradeKey', 16 );
-               }
-       }
-
        /**
         * Create the first user account, grant it sysop and bureaucrat rights
         *
@@ -1364,6 +1438,10 @@ abstract class Installer {
                                $user->setEmail( $this->getVar( '_AdminEmail' ) );
                        }
                        $user->saveSettings();
+
+                       // Update user count
+                       $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
+                       $ssUpdate->doUpdate();
                }
                $status = Status::newGood();
 
@@ -1389,9 +1467,10 @@ abstract class Installer {
                        $params['language'] = $myLang;
                }
 
-               $res = Http::post( $this->mediaWikiAnnounceUrl, array( 'postData' => $params ) );
-               if( !$res ) {
-                       $s->warning( 'config-install-subscribe-fail' );
+               $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
+                       array( 'method' => 'POST', 'postData' => $params ) )->execute();
+               if( !$res->isOK() ) {
+                       $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
                }
        }
 
@@ -1400,7 +1479,7 @@ abstract class Installer {
         *
         * @return Status
         */
-       protected function createMainpage( DatabaseInstaller &$installer ) {
+       protected function createMainpage( DatabaseInstaller $installer ) {
                $status = Status::newGood();
                try {
                        $article = new Article( Title::newMainPage() );
@@ -1409,7 +1488,7 @@ abstract class Installer {
                                                                '',
                                                                EDIT_NEW,
                                                                false,
-                                                               User::newFromName( 'MediaWiki Default' ) );
+                                                               User::newFromName( 'MediaWiki default' ) );
                } catch (MWException $e) {
                        //using raw, because $wgShowExceptionDetails can not be set yet
                        $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
@@ -1455,4 +1534,14 @@ abstract class Installer {
        public function addInstallStep( $callback, $findStep = 'BEGINNING' ) {
                $this->extraInstallSteps[$findStep][] = $callback;
        }
+
+       /**
+        * Disable the time limit for execution.
+        * Some long-running pages (Install, Upgrade) will want to do this
+        */
+       protected function disableTimeLimit() {
+               wfSuppressWarnings();
+               set_time_limit( 0 );
+               wfRestoreWarnings();
+       }
 }