Localisation updates for core and extension messages from translatewiki.net (2011...
[lhc/web/wiklou.git] / includes / installer / Installer.php
index 2d4cfbf..4c48883 100644 (file)
@@ -73,6 +73,7 @@ abstract class Installer {
                'postgres',
                'oracle',
                'sqlite',
+               'ibm_db2',
        );
 
        /**
@@ -304,7 +305,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();
@@ -607,13 +608,10 @@ abstract class Installer {
                $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;
                        }
-                       $allNames[] = $readableName;
+                       $allNames[] = wfMsg( 'config-type-' . $name );
                }
 
                $this->setVar( '_CompiledDBs', $compiledDBs );
@@ -628,8 +626,7 @@ abstract class Installer {
                // 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' );
                        }
                }
@@ -822,7 +819,7 @@ abstract class Installer {
                        $this->showMessage( 'config-gd' );
                        return true;
                } else {
-                       $this->showMessage( 'no-scaling' );
+                       $this->showMessage( 'config-no-scaling' );
                }
        }
 
@@ -1196,7 +1193,9 @@ abstract class Installer {
                 * but we're not opening that can of worms
                 * @see https://bugzilla.wikimedia.org/show_bug.cgi?id=26857
                 */
-               global $wgHooks, $wgAutoloadClasses;
+               global $wgAutoloadClasses;
+               $wgAutoloadClasses = array();
+               
                require( "$IP/includes/DefaultSettings.php" );
 
                foreach( $exts as $e ) {
@@ -1208,8 +1207,7 @@ abstract class Installer {
 
                // Unset everyone else's hooks. Lord knows what someone might be doing
                // in ParserFirstCallInit (see bug 27171)
-               unset( $wgHooks );
-               $wgHooks = array( 'LoadExtensionSchemaUpdates' => $hooksWeWant );
+               $GLOBALS['wgHooks'] = array( 'LoadExtensionSchemaUpdates' => $hooksWeWant );
 
                return Status::newGood();
        }
@@ -1232,8 +1230,7 @@ abstract class Installer {
                        array( 'name' => 'tables',     'callback' => array( $installer, 'createTables' ) ),
                        array( 'name' => 'interwiki',  'callback' => array( $installer, 'populateInterwikiTable' ) ),
                        array( 'name' => 'stats',      'callback' => array( $this, 'populateSiteStats' ) ),
-                       array( 'name' => 'secretkey',  'callback' => array( $this, 'generateSecretKey' ) ),
-                       array( 'name' => 'upgradekey', 'callback' => array( $this, 'generateUpgradeKey' ) ),
+                       array( 'name' => 'keys',       'callback' => array( $this, 'generateKeys' ) ),
                        array( 'name' => 'sysop',      'callback' => array( $this, 'createSysop' ) ),
                        array( 'name' => 'mainpage',   'callback' => array( $this, 'createMainpage' ) ),
                );
@@ -1313,58 +1310,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();
+
+               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 ) );
+                               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 );
-               }
-               return Status::newGood();
-       }
-
        /**
         * Create the first user account, grant it sysop and bureaucrat rights
         *