Checking permissions for $wgUser while doing an edit with another user is not a good...
[lhc/web/wiklou.git] / includes / installer / CoreInstaller.php
index 12440d8..e86ccc5 100644 (file)
@@ -49,6 +49,7 @@ abstract class CoreInstaller extends Installer {
                'wgSecretKey',
                'wgUseInstantCommons',
                'wgUpgradeKey',
+               'wgDefaultSkin',
        );
 
        /**
@@ -83,9 +84,8 @@ abstract class CoreInstaller extends Installer {
                '_CCDone' => false,
                '_Extensions' => array(),
                '_MemCachedServers' => '',
-               '_ExternalHTTP' => false,
-               '_LocalSettingsLocked' => true,
-               '_UpgradeKey' => '',
+               '_UpgradeKeySupplied' => false,
+               '_ExistingDBSettings' => false,
        );
 
        /**
@@ -298,8 +298,8 @@ abstract class CoreInstaller extends Installer {
        /**
         * Get an array of install steps. These could be a plain key like the defaults
         * in $installSteps, or could be an array with a name and a specific callback
-        * There must be a config-install-$step message defined per step, which are 
-        * shown by the CliInstaller.
+        * There must be a config-install-$step message defined per step, which will
+        * be shown on install.
         *
         * @param $installer DatabaseInstaller so we can make callbacks
         * @return array
@@ -315,7 +315,7 @@ abstract class CoreInstaller extends Installer {
                        array( 'name' => 'mainpage',  'callback' => array( $this, 'createMainpage' ) ),
                );
                if( count( $this->getVar( '_Extensions' ) ) ) {
-                       array_unshift( $installSteps, 
+                       array_unshift( $installSteps,
                                array( 'name' => 'extensions', 'callback' => array( $this, 'includeExtensions' ) )
                        );
                }
@@ -374,14 +374,14 @@ abstract class CoreInstaller extends Installer {
        protected function generateSecretKey() {
                return $this->generateSecret( 'wgSecretKey' );
        }
-       
+
        /**
-        * Generate a secret value for a variable using either 
+        * Generate a secret value for a variable using either
         * /dev/urandom or mt_rand() Produce a warning in the later case.
         *
         * @return Status
         */
-       protected function generateSecret( $secretName ) {
+       protected function generateSecret( $secretName, $length = 64 ) {
                if ( wfIsWindows() ) {
                        $file = null;
                } else {
@@ -393,12 +393,12 @@ abstract class CoreInstaller extends Installer {
                $status = Status::newGood();
 
                if ( $file ) {
-                       $secretKey = bin2hex( fread( $file, 32 ) );
+                       $secretKey = bin2hex( fread( $file, $length / 2 ) );
                        fclose( $file );
                } else {
                        $secretKey = '';
 
-                       for ( $i=0; $i<8; $i++ ) {
+                       for ( $i = 0; $i < $length / 8; $i++ ) {
                                $secretKey .= dechex( mt_rand( 0, 0x7fffffff ) );
                        }
 
@@ -411,13 +411,15 @@ abstract class CoreInstaller extends Installer {
        }
 
        /**
-        * Generate a default $wgUpradeKey, Will warn if we had to use 
+        * Generate a default $wgUpgradeKey. Will warn if we had to use
         * mt_rand() instead of /dev/urandom
         *
         * @return Status
         */
-       protected function generateUpgradeKey() {
-               return $this->generateSecret( 'wgUpgradeKey' );
+       public function generateUpgradeKey() {
+               if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
+                       return $this->generateSecret( 'wgUpgradeKey', 16 );
+               }
        }
 
        /**
@@ -453,7 +455,7 @@ abstract class CoreInstaller extends Installer {
 
        /**
         * Insert Main Page with default content.
-        * 
+        *
         * @return Status
         */
        protected function createMainpage( DatabaseInstaller &$installer ) {
@@ -468,9 +470,9 @@ abstract class CoreInstaller extends Installer {
                                                                User::newFromName( 'MediaWiki Default' ) );
                } catch (MWException $e) {
                        //using raw, because $wgShowExceptionDetails can not be set yet
-                       $status->fatal( 'config-install-mainpage-failed', $e->getMessage() ); 
+                       $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
                }
-               
+
                return $status;
        }
 
@@ -494,6 +496,9 @@ abstract class CoreInstaller extends Installer {
                // Allow multiple ob_flush() calls
                $GLOBALS['wgDisableOutputCompression'] = true;
 
+               // Use a sensible cookie prefix (not my_wiki)
+               $GLOBALS['wgCookiePrefix'] = 'mw_installer';
+
                // Some of the environment checks make shell requests, remove limits
                $GLOBALS['wgMaxShellMemory'] = 0;
        }