Merge "Warn if stateful ParserOutput transforms are used"
[lhc/web/wiklou.git] / maintenance / install.php
index 3e632f0..d170c15 100644 (file)
@@ -90,12 +90,42 @@ class CommandLineInstaller extends Maintenance {
                $this->addOption( 'env-checks', "Run environment checks only, don't change anything" );
        }
 
+       public function getDbType() {
+               if ( $this->hasOption( 'env-checks' ) ) {
+                       return Maintenance::DB_NONE;
+               }
+               return parent::getDbType();
+       }
+
        function execute() {
                global $IP;
 
                $siteName = $this->getArg( 0, 'MediaWiki' ); // Will not be set if used with --env-checks
                $adminName = $this->getArg( 1 );
+               $envChecksOnly = $this->hasOption( 'env-checks' );
+
+               $this->setDbPassOption();
+               if ( !$envChecksOnly ) {
+                       $this->setPassOption();
+               }
+
+               $installer = InstallerOverrides::getCliInstaller( $siteName, $adminName, $this->mOptions );
+
+               $status = $installer->doEnvironmentChecks();
+               if ( $status->isGood() ) {
+                       $installer->showMessage( 'config-env-good' );
+               } else {
+                       $installer->showStatusMessage( $status );
+
+                       return;
+               }
+               if ( !$envChecksOnly ) {
+                       $installer->execute();
+                       $installer->writeConfigurationFile( $this->getOption( 'confpath', $IP ) );
+               }
+       }
 
+       private function setDbPassOption() {
                $dbpassfile = $this->getOption( 'dbpassfile' );
                if ( $dbpassfile !== null ) {
                        if ( $this->getOption( 'dbpass' ) !== null ) {
@@ -106,11 +136,13 @@ class CommandLineInstaller extends Maintenance {
                        $dbpass = file_get_contents( $dbpassfile ); // returns false on failure
                        MediaWiki\restoreWarnings();
                        if ( $dbpass === false ) {
-                               $this->error( "Couldn't open $dbpassfile", true );
+                               $this->fatalError( "Couldn't open $dbpassfile" );
                        }
                        $this->mOptions['dbpass'] = trim( $dbpass, "\r\n" );
                }
+       }
 
+       private function setPassOption() {
                $passfile = $this->getOption( 'passfile' );
                if ( $passfile !== null ) {
                        if ( $this->getOption( 'pass' ) !== null ) {
@@ -121,26 +153,11 @@ class CommandLineInstaller extends Maintenance {
                        $pass = file_get_contents( $passfile ); // returns false on failure
                        MediaWiki\restoreWarnings();
                        if ( $pass === false ) {
-                               $this->error( "Couldn't open $passfile", true );
+                               $this->fatalError( "Couldn't open $passfile" );
                        }
                        $this->mOptions['pass'] = trim( $pass, "\r\n" );
                } elseif ( $this->getOption( 'pass' ) === null ) {
-                       $this->error( 'You need to provide the option "pass" or "passfile"', true );
-               }
-
-               $installer = InstallerOverrides::getCliInstaller( $siteName, $adminName, $this->mOptions );
-
-               $status = $installer->doEnvironmentChecks();
-               if ( $status->isGood() ) {
-                       $installer->showMessage( 'config-env-good' );
-               } else {
-                       $installer->showStatusMessage( $status );
-
-                       return;
-               }
-               if ( !$this->hasOption( 'env-checks' ) ) {
-                       $installer->execute();
-                       $installer->writeConfigurationFile( $this->getOption( 'confpath', $IP ) );
+                       $this->fatalError( 'You need to provide the option "pass" or "passfile"' );
                }
        }
 
@@ -151,6 +168,6 @@ class CommandLineInstaller extends Maintenance {
        }
 }
 
-$maintClass = 'CommandLineInstaller';
+$maintClass = CommandLineInstaller::class;
 
 require_once RUN_MAINTENANCE_IF_MAIN;