Merge "Follow-up I68179974: Remove from 1.33 RL, backported to 1.32"
[lhc/web/wiklou.git] / includes / installer / DatabaseInstaller.php
index e6ee70e..6315de4 100644 (file)
@@ -23,6 +23,8 @@
 use Wikimedia\Rdbms\LBFactorySingle;
 use Wikimedia\Rdbms\Database;
 use Wikimedia\Rdbms\IDatabase;
+use Wikimedia\Rdbms\DBExpectedError;
+use Wikimedia\Rdbms\DBConnectionError;
 
 /**
  * Base class for DBMS-specific installation helper classes.
@@ -371,6 +373,7 @@ abstract class DatabaseInstaller {
        /**
         * Perform database upgrades
         *
+        * @suppress SecurityCheck-XSS Escaping provided by $this->outputHandler
         * @return bool
         */
        public function doUpgrade() {
@@ -382,6 +385,7 @@ abstract class DatabaseInstaller {
                $up = DatabaseUpdater::newForDB( $this->db );
                try {
                        $up->doUpdates();
+                       $up->purgeCache();
                } catch ( MWException $e ) {
                        echo "\nAn error occurred:\n";
                        echo $e->getText();
@@ -391,7 +395,6 @@ abstract class DatabaseInstaller {
                        echo $e->getMessage();
                        $ret = false;
                }
-               $up->purgeCache();
                ob_end_flush();
 
                return $ret;
@@ -620,7 +623,12 @@ abstract class DatabaseInstaller {
                        return false;
                }
 
-               if ( !$this->db->selectDB( $this->getVar( 'wgDBname' ) ) ) {
+               try {
+                       $this->db->selectDB( $this->getVar( 'wgDBname' ) );
+               } catch ( DBConnectionError $e ) {
+                       // Don't catch DBConnectionError
+                       throw $e;
+               } catch ( DBExpectedError $e ) {
                        return false;
                }