* @ingroup Maintenance
*/
-// Checking for old versions of PHP is done in Maintenance.php
-// We need to use dirname( __FILE__ ) here cause __DIR__ is PHP5.3+
-// @codingStandardsIgnoreStart MediaWiki.Usage.DirUsage.FunctionFound
-require_once dirname( __FILE__ ) . '/Maintenance.php';
-// @codingStandardsIgnoreEnd
+require_once __DIR__ . '/Maintenance.php';
define( 'MW_CONFIG_CALLBACK', 'Installer::overrideConfig' );
define( 'MEDIAWIKI_INSTALL', true );
$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 ) {
}
$this->mOptions['dbpass'] = trim( $dbpass, "\r\n" );
}
+ }
+ private function setPassOption() {
$passfile = $this->getOption( 'passfile' );
if ( $passfile !== null ) {
if ( $this->getOption( 'pass' ) !== null ) {
} 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() {