X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=blobdiff_plain;f=includes%2Finstaller%2FCliInstaller.php;h=0ff34b086f63ea96d55539d3d698445ed4523ce0;hb=d9eec3c9124d87fd44e6917d5b1512b78352afb3;hp=c008333e473791422b7d36d79004a80165706a74;hpb=7f2f49ad2368ae27f2d4db69b44c5f997197725e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/CliInstaller.php b/includes/installer/CliInstaller.php index c008333e47..0ff34b086f 100644 --- a/includes/installer/CliInstaller.php +++ b/includes/installer/CliInstaller.php @@ -21,6 +21,7 @@ * @ingroup Deployment */ +use MediaWiki\Installer\InstallException; use MediaWiki\MediaWikiServices; /** @@ -51,6 +52,7 @@ class CliInstaller extends Installer { * @param string $siteName * @param string|null $admin * @param array $options + * @throws InstallException */ function __construct( $siteName, $admin = null, array $options = [] ) { global $wgContLang; @@ -114,22 +116,30 @@ class CliInstaller extends Installer { $status = $this->validateExtensions( 'extension', 'extensions', $options['extensions'] ); if ( !$status->isOK() ) { - $this->showStatusMessage( $status ); + throw new InstallException( $status ); } $this->setVar( '_Extensions', $status->value ); } elseif ( isset( $options['with-extensions'] ) ) { - $this->setVar( '_Extensions', array_keys( $this->findExtensions() ) ); + $status = $this->findExtensions(); + if ( !$status->isOK() ) { + throw new InstallException( $status ); + } + $this->setVar( '_Extensions', array_keys( $status->value ) ); } // Set up the default skins if ( isset( $options['skins'] ) ) { $status = $this->validateExtensions( 'skin', 'skins', $options['skins'] ); if ( !$status->isOK() ) { - $this->showStatusMessage( $status ); + throw new InstallException( $status ); } $skins = $status->value; } else { - $skins = array_keys( $this->findExtensions( 'skins' ) ); + $status = $this->findExtensions( 'skins' ); + if ( !$status->isOK() ) { + throw new InstallException( $status ); + } + $skins = array_keys( $status->value ); } $this->setVar( '_Skins', $skins ); @@ -165,17 +175,34 @@ class CliInstaller extends Installer { * Main entry point. */ public function execute() { + // If APC is available, use that as the MainCacheType, instead of nothing. + // This is hacky and should be consolidated with WebInstallerOptions. + // This is here instead of in __construct(), because it should run run after + // doEnvironmentChecks(), which populates '_Caches'. + if ( count( $this->getVar( '_Caches' ) ) ) { + // We detected a CACHE_ACCEL implementation, use it. + $this->setVar( '_MainCacheType', 'accel' ); + } + $vars = Installer::getExistingLocalSettings(); if ( $vars ) { - $this->showStatusMessage( - Status::newFatal( "config-localsettings-cli-upgrade" ) - ); + $status = Status::newFatal( "config-localsettings-cli-upgrade" ); + $this->showStatusMessage( $status ); + return $status; } - $this->performInstallation( + $result = $this->performInstallation( [ $this, 'startStage' ], [ $this, 'endStage' ] ); + // PerformInstallation bails on a fatal, so make sure the last item + // completed before giving 'next.' Likewise, only provide back on failure + $lastStepStatus = end( $result ); + if ( $lastStepStatus->isOK() ) { + return Status::newGood(); + } else { + return $lastStepStatus; + } } /** @@ -239,11 +266,6 @@ class CliInstaller extends Installer { $this->showMessage( ...$w ); } } - - if ( !$status->isOK() ) { - echo "\n"; - exit( 1 ); - } } public function envCheckPath() {