Merge "Installer: page refresh should refresh list of supported DBs"
[lhc/web/wiklou.git] / includes / installer / Installer.php
index 35a546c..d41f7b8 100644 (file)
@@ -46,6 +46,14 @@ abstract class Installer {
         */
        protected $settings;
 
+
+       /**
+        * List of detected DBs, access using getCompiledDBs().
+        *
+        * @var array
+        */
+       protected $compiledDBs;
+
        /**
         * Cached DB installer instances, access using getDBInstaller().
         *
@@ -175,7 +183,6 @@ abstract class Installer {
        protected $internalDefaults = array(
                '_UserLang' => 'en',
                '_Environment' => false,
-               '_CompiledDBs' => array(),
                '_SafeMode' => false,
                '_RaiseMemory' => false,
                '_UpgradeDone' => false,
@@ -370,7 +377,7 @@ abstract class Installer {
                                }
                        }
                }
-               $this->setVar( '_CompiledDBs', $compiledDBs );
+               $this->compiledDBs = $compiledDBs;
 
                $this->parserTitle = Title::newFromText( 'Installer' );
                $this->parserOptions = new ParserOptions; // language will  be wrong :(
@@ -451,6 +458,15 @@ abstract class Installer {
                }
        }
 
+       /**
+        * Get a list of DBs supported by current PHP setup
+        *
+        * @return array
+        */
+       public function getCompiledDBs() {
+               return $this->compiledDBs;
+       }
+
        /**
         * Get an instance of DatabaseInstaller for the specified DB type.
         *
@@ -491,10 +507,10 @@ abstract class Installer {
                }
                unset( $_lsExists );
 
-               require( "$IP/includes/DefaultSettings.php" );
-               require( "$IP/LocalSettings.php" );
+               require "$IP/includes/DefaultSettings.php";
+               require "$IP/LocalSettings.php";
                if ( file_exists( "$IP/AdminSettings.php" ) ) {
-                       require( "$IP/AdminSettings.php" );
+                       require "$IP/AdminSettings.php";
                }
                return get_defined_vars();
        }
@@ -651,13 +667,7 @@ abstract class Installer {
                        $allNames[] = wfMessage( "config-type-$name" )->text();
                }
 
-               // cache initially available databases to make sure that everything will be displayed correctly
-               // after a refresh on env checks page
-               $databases = $this->getVar( '_CompiledDBs-preFilter' );
-               if ( !$databases ) {
-                       $databases = $this->getVar( '_CompiledDBs' );
-                       $this->setVar( '_CompiledDBs-preFilter', $databases );
-               }
+               $databases = $this->getCompiledDBs();
 
                $databases = array_flip ( $databases );
                foreach ( array_keys( $databases ) as $db ) {
@@ -676,7 +686,6 @@ abstract class Installer {
                        // @todo FIXME: This only works for the web installer!
                        return false;
                }
-               $this->setVar( '_CompiledDBs', $databases );
                return true;
        }
 
@@ -970,6 +979,7 @@ abstract class Installer {
 
        /**
         * Environment check for setting the preferred PHP file extension.
+        * @return bool
         */
        protected function envCheckExtension() {
                // @todo FIXME: Detect this properly
@@ -983,7 +993,7 @@ abstract class Installer {
        }
 
        /**
-        * TODO: document
+        * Environment check for preferred locale in shell
         * @return bool
         */
        protected function envCheckShellLocale() {
@@ -1002,7 +1012,7 @@ abstract class Installer {
                        return true;
                }
 
-               $lines = wfArrayMap( 'trim', explode( "\n", $lines ) );
+               $lines = array_map( 'trim', explode( "\n", $lines ) );
                $candidatesByLocale = array();
                $candidatesByLang = array();
 
@@ -1057,7 +1067,7 @@ abstract class Installer {
        }
 
        /**
-        * TODO: document
+        * Environment check for the permissions of the uploads directory
         * @return bool
         */
        protected function envCheckUploadsDirectory() {
@@ -1074,22 +1084,16 @@ 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
+        * Checks if suhosin.get.max_value_length is set, and if so generate
+        * a warning because it decreases ResourceLoader performance.
         * @return bool
         */
        protected function envCheckSuhosinMaxValueLength() {
                $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
-               if ( $maxValueLength > 0 ) {
-                       if ( $maxValueLength < 1024 ) {
-                               # Only warn if the value is below the sane 1024
-                               $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength );
-                       }
-               } else {
-                       $maxValueLength = -1;
+               if ( $maxValueLength > 0 &&  $maxValueLength < 1024 ) {
+                       // Only warn if the value is below the sane 1024
+                       $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength );
                }
-               $this->setVar( 'wgResourceLoaderMaxQueryLength', $maxValueLength );
                return true;
        }
 
@@ -1283,7 +1287,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;
                                }
@@ -1390,10 +1394,10 @@ abstract class Installer {
                global $wgAutoloadClasses;
                $wgAutoloadClasses = array();
 
-               require( "$IP/includes/DefaultSettings.php" );
+               require "$IP/includes/DefaultSettings.php";
 
                foreach ( $exts as $e ) {
-                       require_once( "$IP/extensions/$e/$e.php" );
+                       require_once "$IP/extensions/$e/$e.php";
                }
 
                $hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?
@@ -1560,7 +1564,7 @@ abstract class Installer {
 
                        try {
                                $user->setPassword( $this->getVar( '_AdminPassword' ) );
-                       } catch( PasswordError $pwe ) {
+                       } catch ( PasswordError $pwe ) {
                                return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
                        }