saper has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/248585

Change subject: Installer: check for available databases
......................................................................

Installer: check for available databases

- CLI installer should not stop
  if a prerequisite of some other
  database is not met

- Web installer should not offer
  databases failing prerequisite
  check.

Bug: T46511
Change-Id: I91ab978f9e7060f2942d72cce2c24564fe66f701
---
M includes/installer/CliInstaller.php
M includes/installer/Installer.php
M includes/installer/WebInstaller.php
M includes/installer/WebInstallerPage.php
4 files changed, 58 insertions(+), 36 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/85/248585/1

diff --git a/includes/installer/CliInstaller.php 
b/includes/installer/CliInstaller.php
index 7290740..2cb6165 100644
--- a/includes/installer/CliInstaller.php
+++ b/includes/installer/CliInstaller.php
@@ -188,7 +188,7 @@
        public function showHelpBox( $msg /*, ... */ ) {
        }
 
-       public function showStatusMessage( Status $status ) {
+       public function displayStatusMessage( Status $status ) {
                $warnings = array_merge( $status->getWarningsArray(),
                        $status->getErrorsArray() );
 
@@ -197,6 +197,10 @@
                                call_user_func_array( array( $this, 
'showMessage' ), $w );
                        }
                }
+       }
+
+       public function showStatusMessage( Status $status ) {
+               $this->displayStatusMessage( $status );
 
                if ( !$status->isOk() ) {
                        echo "\n";
diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php
index 064bd6d..0b0f728 100644
--- a/includes/installer/Installer.php
+++ b/includes/installer/Installer.php
@@ -201,6 +201,7 @@
                '_UpgradeDone' => false,
                '_InstallDone' => false,
                '_Caches' => array(),
+               '_AvailableDBs' => array(),
                '_InstallPassword' => '',
                '_SameAccount' => true,
                '_CreateDBAccount' => false,
@@ -350,6 +351,14 @@
 
        /**
         * Show a message to the installing user by using a Status object
+        * Does not exit on fatal error
+        * @param Status $status
+        */
+       abstract public function displayStatusMessage( Status $status );
+
+       /**
+        * Show a message to the installing user by using a Status object
+        * May exit on fatal error
         * @param Status $status
         */
        abstract public function showStatusMessage( Status $status );
@@ -520,7 +529,6 @@
                        $class = ucfirst( $type ) . 'Installer';
                        $this->dbInstallers[$type] = new $class( $this );
                }
-
                return $this->dbInstallers[$type];
        }
 
@@ -724,17 +732,18 @@
                        $installer = $this->getDBInstaller( $db );
                        $status = $installer->checkPrerequisites();
                        if ( !$status->isGood() ) {
-                               $this->showStatusMessage( $status );
+                               $this->displayStatusMessage( $status );
                        }
                        if ( !$status->isOK() ) {
                                unset( $databases[$db] );
                        }
                }
                $databases = array_flip( $databases );
+               $this->setVar( '_AvailableDBs', $databases );
+
                if ( !$databases ) {
                        $this->showError( 'config-no-db', $wgLang->commaList( 
$allNames ), count( $allNames ) );
 
-                       // @todo FIXME: This only works for the web installer!
                        return false;
                }
 
diff --git a/includes/installer/WebInstaller.php 
b/includes/installer/WebInstaller.php
index 67a4def..1614f3c 100644
--- a/includes/installer/WebInstaller.php
+++ b/includes/installer/WebInstaller.php
@@ -733,12 +733,18 @@
        /**
         * @param Status $status
         */
-       public function showStatusMessage( Status $status ) {
+       public function displayStatusMessage( Status $status ) {
                $errors = array_merge( $status->getErrorsArray(), 
$status->getWarningsArray() );
                foreach ( $errors as $error ) {
                        call_user_func_array( array( $this, 'showMessage' ), 
$error );
                }
        }
+       /**
+        * @param Status $status
+        */
+       public function showStatusMessage( Status $status ) {
+               $this->displayStatusMessage( $status );
+       }
 
        /**
         * Label a control by wrapping a config-input div around it and putting 
a
diff --git a/includes/installer/WebInstallerPage.php 
b/includes/installer/WebInstallerPage.php
index 0d11463..c05bc7f 100644
--- a/includes/installer/WebInstallerPage.php
+++ b/includes/installer/WebInstallerPage.php
@@ -523,6 +523,8 @@
                        }
                }
 
+               $availableDBs = $this->getVar( '_AvailableDBs' );
+
                $this->startForm();
 
                $types = "<ul class=\"config-settings-block\">\n";
@@ -538,39 +540,40 @@
                $this->addHTML( $this->parent->getInfoBox(
                        wfMessage( 'config-support-info', trim( $dbSupport ) 
)->text() ) );
 
-               // 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->getCompiledDBs();
-               if ( !in_array( $defaultType, $compiledDBs ) ) {
-                       $defaultType = $compiledDBs[0];
-               }
+               if ( $availableDBs ) {
+                       // 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.
+                       if ( !in_array( $defaultType, $availableDBs ) ) {
+                               $defaultType = $availableDBs[0];
+                       }
 
-               foreach ( $compiledDBs as $type ) {
-                       $installer = $this->parent->getDBInstaller( $type );
-                       $types .=
-                               '<li>' .
-                               Xml::radioLabel(
-                                       $installer->getReadableName(),
-                                       'DBType',
-                                       $type,
-                                       "DBType_$type",
-                                       $type == $defaultType,
-                                       array( 'class' => 'dbRadio', 'rel' => 
"DB_wrapper_$type" )
-                               ) .
-                               "</li>\n";
+                       foreach ( $availableDBs as $type ) {
+                               $installer = $this->parent->getDBInstaller( 
$type );
+                               $types .=
+                                       '<li>' .
+                                       Xml::radioLabel(
+                                               $installer->getReadableName(),
+                                               'DBType',
+                                               $type,
+                                               "DBType_$type",
+                                               $type == $defaultType,
+                                               array( 'class' => 'dbRadio', 
'rel' => "DB_wrapper_$type" )
+                                       ) .
+                                       "</li>\n";
 
-                       // Messages: config-header-mysql, 
config-header-postgres, config-header-oracle,
-                       // config-header-sqlite
-                       $settings .= Html::openElement(
-                                       'div',
-                                       array(
-                                               'id' => 'DB_wrapper_' . $type,
-                                               'class' => 'dbWrapper'
-                                       )
-                               ) .
-                               Html::element( 'h3', array(), wfMessage( 
'config-header-' . $type )->text() ) .
-                               $installer->getConnectForm() .
-                               "</div>\n";
+                               // Messages: config-header-mysql, 
config-header-postgres, config-header-oracle,
+                               // config-header-sqlite
+                               $settings .= Html::openElement(
+                                               'div',
+                                               array(
+                                                       'id' => 'DB_wrapper_' . 
$type,
+                                                       'class' => 'dbWrapper'
+                                               )
+                                       ) .
+                                       Html::element( 'h3', array(), 
wfMessage( 'config-header-' . $type )->text() ) .
+                                       $installer->getConnectForm() .
+                                       "</div>\n";
+                       }
                }
 
                $types .= "</ul><br style=\"clear: left\"/>\n";

-- 
To view, visit https://gerrit.wikimedia.org/r/248585
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I91ab978f9e7060f2942d72cce2c24564fe66f701
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: saper <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to