Don't ask for password for env-checks in install.php
authoraddshore <addshorewiki@gmail.com>
Tue, 4 Jul 2017 18:22:23 +0000 (19:22 +0100)
committeraddshore <addshorewiki@gmail.com>
Tue, 4 Jul 2017 18:31:22 +0000 (19:31 +0100)
Bug: T169669
Change-Id: I00dbaca0e4532ecc499317ec8f1cb7f9eb872db3

maintenance/install.php

index 3e632f0..81b6d9c 100644 (file)
@@ -95,7 +95,30 @@ class CommandLineInstaller extends Maintenance {
 
                $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 ) {
@@ -110,7 +133,9 @@ class CommandLineInstaller extends Maintenance {
                        }
                        $this->mOptions['dbpass'] = trim( $dbpass, "\r\n" );
                }
+       }
 
+       private function setPassOption() {
                $passfile = $this->getOption( 'passfile' );
                if ( $passfile !== null ) {
                        if ( $this->getOption( 'pass' ) !== null ) {
@@ -127,21 +152,6 @@ class CommandLineInstaller extends Maintenance {
                } 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 ) );
-               }
        }
 
        function validateParamsAndArgs() {