Installer: page refresh should refresh list of supported DBs
authorOren Held <oren@held.org.il>
Sat, 25 May 2013 10:59:13 +0000 (13:59 +0300)
committerOren Held <oren@held.org.il>
Sat, 25 May 2013 10:59:13 +0000 (13:59 +0300)
There's no need to cache _CompiledDBs's value from the first installer load.
Instead, the list should be regenerated on every page load, as it's merely being
used for displaying the user list of DBs to choose from.

This solves a common setup confusion, where user starts with no DB support, gets
a friendly error message, installs php5-mysql as requested, but refreshing the
page won't make the error go away.

Bug: 31533
Change-Id: I2e7e5b4f72e7c11706d491a205e202008e2511da

includes/installer/Installer.php
includes/installer/WebInstallerPage.php

index b1517e4..169e89c 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.
         *
@@ -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;
        }
 
index 8a9fc2d..4a57260 100644 (file)
@@ -469,7 +469,7 @@ class WebInstaller_DBConnect extends WebInstallerPage {
 
                // It's possible that the library for the default DB type is not compiled in.
                // In that case, instead select the first supported DB type in the list.
-               $compiledDBs = $this->parent->getVar( '_CompiledDBs' );
+               $compiledDBs = $this->parent->getCompiledDBs();
                if ( !in_array( $defaultType, $compiledDBs ) ) {
                        $defaultType = $compiledDBs[0];
                }