|
@@ -35,8 +35,8 @@ use OC\Hooks\BasicEmitter;
|
|
|
use OC\IntegrityCheck\Checker;
|
|
|
use OC_App;
|
|
|
use OCP\IConfig;
|
|
|
-use OC\Setup;
|
|
|
use OCP\ILogger;
|
|
|
+use OCP\Util;
|
|
|
use Symfony\Component\EventDispatcher\GenericEvent;
|
|
|
|
|
|
/**
|
|
@@ -59,12 +59,6 @@ class Updater extends BasicEmitter {
|
|
|
/** @var Checker */
|
|
|
private $checker;
|
|
|
|
|
|
- /** @var bool */
|
|
|
- private $simulateStepEnabled;
|
|
|
-
|
|
|
- /** @var bool */
|
|
|
- private $updateStepEnabled;
|
|
|
-
|
|
|
/** @var bool */
|
|
|
private $skip3rdPartyAppsDisable;
|
|
|
|
|
@@ -87,29 +81,6 @@ class Updater extends BasicEmitter {
|
|
|
$this->log = $log;
|
|
|
$this->config = $config;
|
|
|
$this->checker = $checker;
|
|
|
- $this->simulateStepEnabled = true;
|
|
|
- $this->updateStepEnabled = true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Sets whether the database migration simulation must
|
|
|
- * be enabled.
|
|
|
- * This can be set to false to skip this test.
|
|
|
- *
|
|
|
- * @param bool $flag true to enable simulation, false otherwise
|
|
|
- */
|
|
|
- public function setSimulateStepEnabled($flag) {
|
|
|
- $this->simulateStepEnabled = $flag;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Sets whether the update must be performed.
|
|
|
- * This can be set to false to skip the actual update.
|
|
|
- *
|
|
|
- * @param bool $flag true to enable update, false otherwise
|
|
|
- */
|
|
|
- public function setUpdateStepEnabled($flag) {
|
|
|
- $this->updateStepEnabled = $flag;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -131,9 +102,9 @@ class Updater extends BasicEmitter {
|
|
|
public function upgrade() {
|
|
|
$this->emitRepairEvents();
|
|
|
|
|
|
- $logLevel = $this->config->getSystemValue('loglevel', \OCP\Util::WARN);
|
|
|
+ $logLevel = $this->config->getSystemValue('loglevel', Util::WARN);
|
|
|
$this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
|
|
|
- $this->config->setSystemValue('loglevel', \OCP\Util::DEBUG);
|
|
|
+ $this->config->setSystemValue('loglevel', Util::DEBUG);
|
|
|
|
|
|
$wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
|
|
|
|
|
@@ -254,68 +225,48 @@ class Updater extends BasicEmitter {
|
|
|
$repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher());
|
|
|
$repair->run();
|
|
|
|
|
|
- // simulate DB upgrade
|
|
|
- if ($this->simulateStepEnabled) {
|
|
|
- $this->checkCoreUpgrade();
|
|
|
-
|
|
|
- // simulate apps DB upgrade
|
|
|
- $this->checkAppUpgrade($currentVersion);
|
|
|
+ $this->doCoreUpgrade();
|
|
|
|
|
|
+ try {
|
|
|
+ // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
|
|
|
+ Setup::installBackgroundJobs();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ throw new \Exception($e->getMessage());
|
|
|
}
|
|
|
|
|
|
- if ($this->updateStepEnabled) {
|
|
|
- $this->doCoreUpgrade();
|
|
|
-
|
|
|
- try {
|
|
|
- // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
|
|
|
- Setup::installBackgroundJobs();
|
|
|
- } catch (\Exception $e) {
|
|
|
- throw new \Exception($e->getMessage());
|
|
|
- }
|
|
|
-
|
|
|
- // update all shipped apps
|
|
|
- $disabledApps = $this->checkAppsRequirements();
|
|
|
- $this->doAppUpgrade();
|
|
|
+ // update all shipped apps
|
|
|
+ $disabledApps = $this->checkAppsRequirements();
|
|
|
+ $this->doAppUpgrade();
|
|
|
|
|
|
- // upgrade appstore apps
|
|
|
- $this->upgradeAppStoreApps($disabledApps);
|
|
|
-
|
|
|
- // install new shipped apps on upgrade
|
|
|
- OC_App::loadApps('authentication');
|
|
|
- $errors = Installer::installShippedApps(true);
|
|
|
- foreach ($errors as $appId => $exception) {
|
|
|
- /** @var \Exception $exception */
|
|
|
- $this->log->logException($exception, ['app' => $appId]);
|
|
|
- $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
|
|
|
- }
|
|
|
+ // upgrade appstore apps
|
|
|
+ $this->upgradeAppStoreApps($disabledApps);
|
|
|
|
|
|
- // post-upgrade repairs
|
|
|
- $repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher());
|
|
|
- $repair->run();
|
|
|
+ // install new shipped apps on upgrade
|
|
|
+ OC_App::loadApps('authentication');
|
|
|
+ $errors = Installer::installShippedApps(true);
|
|
|
+ foreach ($errors as $appId => $exception) {
|
|
|
+ /** @var \Exception $exception */
|
|
|
+ $this->log->logException($exception, ['app' => $appId]);
|
|
|
+ $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
|
|
|
+ }
|
|
|
|
|
|
- //Invalidate update feed
|
|
|
- $this->config->setAppValue('core', 'lastupdatedat', 0);
|
|
|
+ // post-upgrade repairs
|
|
|
+ $repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher());
|
|
|
+ $repair->run();
|
|
|
|
|
|
- // Check for code integrity if not disabled
|
|
|
- if(\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) {
|
|
|
- $this->emit('\OC\Updater', 'startCheckCodeIntegrity');
|
|
|
- $this->checker->runInstanceVerification();
|
|
|
- $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity');
|
|
|
- }
|
|
|
+ //Invalidate update feed
|
|
|
+ $this->config->setAppValue('core', 'lastupdatedat', 0);
|
|
|
|
|
|
- // only set the final version if everything went well
|
|
|
- $this->config->setSystemValue('version', implode('.', \OCP\Util::getVersion()));
|
|
|
- $this->config->setAppValue('core', 'vendor', $this->getVendor());
|
|
|
+ // Check for code integrity if not disabled
|
|
|
+ if(\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) {
|
|
|
+ $this->emit('\OC\Updater', 'startCheckCodeIntegrity');
|
|
|
+ $this->checker->runInstanceVerification();
|
|
|
+ $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity');
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- protected function checkCoreUpgrade() {
|
|
|
- $this->emit('\OC\Updater', 'dbSimulateUpgradeBefore');
|
|
|
-
|
|
|
- // simulate core DB upgrade
|
|
|
- \OC_DB::simulateUpdateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
|
|
|
-
|
|
|
- $this->emit('\OC\Updater', 'dbSimulateUpgrade');
|
|
|
+ // only set the final version if everything went well
|
|
|
+ $this->config->setSystemValue('version', implode('.', Util::getVersion()));
|
|
|
+ $this->config->setAppValue('core', 'vendor', $this->getVendor());
|
|
|
}
|
|
|
|
|
|
protected function doCoreUpgrade() {
|
|
@@ -424,7 +375,7 @@ class Updater extends BasicEmitter {
|
|
|
private function checkAppsRequirements() {
|
|
|
$isCoreUpgrade = $this->isCodeUpgrade();
|
|
|
$apps = OC_App::getEnabledApps();
|
|
|
- $version = \OCP\Util::getVersion();
|
|
|
+ $version = Util::getVersion();
|
|
|
$disabledApps = [];
|
|
|
foreach ($apps as $app) {
|
|
|
// check if the app is compatible with this version of ownCloud
|
|
@@ -461,7 +412,7 @@ class Updater extends BasicEmitter {
|
|
|
*/
|
|
|
private function isCodeUpgrade() {
|
|
|
$installedVersion = $this->config->getSystemValue('version', '0.0.0');
|
|
|
- $currentVersion = implode('.', \OCP\Util::getVersion());
|
|
|
+ $currentVersion = implode('.', Util::getVersion());
|
|
|
if (version_compare($currentVersion, $installedVersion, '>')) {
|
|
|
return true;
|
|
|
}
|