Make this public again, MysqlInstaller uses it :(
[lhc/web/wiklou.git] / includes / installer / Installer.php
index 0380442..2492b23 100644 (file)
@@ -11,9 +11,8 @@ abstract class Installer {
         * 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.
-        * @protected
         */
-       var $defaultVarNames = array(
+       protected $defaultVarNames = array(
                'wgSitename',
                'wgPasswordSender',
                'wgLanguageCode', 
@@ -44,9 +43,8 @@ abstract class Installer {
         * Variables that are stored alongside globals, and are used for any 
         * configuration of the installation process aside from the MediaWiki 
         * configuration. Map of names to defaults.
-        * @protected
         */
-       var $internalDefaults = array(
+       protected $internalDefaults = array(
                '_UserLang' => 'en',
                '_Environment' => false,
                '_CompiledDBs' => array(),
@@ -78,9 +76,8 @@ abstract class Installer {
         *
         * To add a new type, create a <type>Installer class and a Database<type> 
         * class, and add a config-type-<type> message to MessagesEn.php.
-        * @private
         */
-       var $dbTypes = array(
+       private $dbTypes = array(
                'mysql',
                'postgres',
                'sqlite',
@@ -94,17 +91,15 @@ abstract class Installer {
 
        /**
         * Cached DB installer instances, access using getDBInstaller()
-        * @private
         */
-       var $dbInstallers = array();
+       private $dbInstallers = array();
 
        /**
         * A list of environment check methods called by doEnvironmentChecks(). 
         * These may output warnings using showMessage(), and/or abort the 
         * installation process by returning false.
-        * @protected
         */
-       var $envChecks = array( 
+       protected $envChecks = array(
                'envLatestVersion',
                'envCheckDB',
                'envCheckRegisterGlobals',
@@ -126,6 +121,10 @@ abstract class Installer {
                'envCheckUploadsDirectory',
        );
 
+       /**
+        * Steps for installation.
+        * @TODO Should be protected...
+        */
        var $installSteps = array(
                'database',
                'tables',
@@ -137,9 +136,8 @@ abstract class Installer {
 
        /**
         * Known object cache types and the functions used to test for their existence
-        * @protected
         */
-       var $objectCaches = array( 
+       protected $objectCaches = array(
                'xcache' => 'xcache_get',
                'apc' => 'apc_fetch',
                'eaccel' => 'eaccelerator_get',
@@ -207,9 +205,8 @@ abstract class Installer {
        );
        /**
         * Cached Title and ParserOptions used by parse()
-        * @private
         */
-       var $parserTitle, $parserOptions;
+       private $parserTitle, $parserOptions;
 
        /**
         * Constructor, always call this from child classes
@@ -224,6 +221,10 @@ abstract class Installer {
                $wgExtensionMessagesFiles['MediawikiInstaller'] =
                        './includes/installer/Installer.i18n.php';
 
+               global $wgUser;
+               $wgUser = User::newFromId( 0 );
+               // Having a user with id = 0 safeguards us from DB access via User::loadOptions()
+
                // Set our custom <doclink> hook
                global $wgHooks;
                $wgHooks['ParserFirstCallInit'][] = array( $this, 'registerDocLink' );
@@ -576,7 +577,9 @@ abstract class Installer {
                                        return $command;
 
                                $file = str_replace( '$1', $command, $versionInfo[0] );
-                               if ( strstr( wfShellExec( $file ), $versionInfo[1]) !== false )
+                               # Should maybe be wfShellExec( $file), but runs into a ulimit, see
+                               # http://www.mediawiki.org/w/index.php?title=New-installer_issues&diff=prev&oldid=335456 
+                               if ( strstr( `$file`, $versionInfo[1]) !== false )
                                        return $command;
                        }
                }
@@ -866,6 +869,12 @@ abstract class Installer {
                return $status;
        }
 
+       public function installUser() {
+               $installer = $this->getDBInstaller( $this->getVar( 'wgDBtype' ) );
+               $status = $installer->setupUser();
+               return $status;
+       }
+
        public function installTables() {
                $installer = $this->getDBInstaller();
                $status = $installer->createTables();
@@ -932,6 +941,31 @@ abstract class Installer {
                return $localSettings->writeLocalSettings();
        }
 
+       /**
+        * Determine if LocalSettings exists. If it does, return an appropriate
+        * status for whether we should can upgrade or not
+        * @return Status
+        */
+       function getLocalSettingsStatus() {
+               global $IP;
+
+               $status = Status::newGood();
+
+               wfSuppressWarnings();
+               $ls = file_exists( "$IP/LocalSettings.php" );
+               wfRestoreWarnings();
+               
+               if( $ls ) {
+                       if( $this->getDBInstaller()->needsUpgrade() ) {
+                               $status->warning( 'config-localsettings-upgrade' );
+                       }
+                       else {
+                               $status->fatal( 'config-localsettings-noupgrade' );
+                       }
+               }
+               return $status;
+       }
+
        /**
         * On POSIX systems return the primary group of the webserver we're running under.
         * On other systems just returns null.