/** * runs the update actions in maintenance mode, does not upgrade the source files * except the main .htaccess file * * @param string $currentVersion current version to upgrade to * @param string $installedVersion previous version from which to upgrade from * * @throws \Exception */ private function doUpgrade($currentVersion, $installedVersion) { // Stop update if the update is over several major versions $allowedPreviousVersion = $this->getAllowedPreviousVersion(); if (!self::isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersion)) { throw new \Exception('Updates between multiple major versions and downgrades are unsupported.'); } // Update .htaccess files try { Setup::updateHtaccess(); Setup::protectDataDirectory(); } catch (\Exception $e) { throw new \Exception($e->getMessage()); } // create empty file in data dir, so we can later find // out that this is indeed an ownCloud data directory // (in case it didn't exist before) file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); // pre-upgrade repairs $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); } if ($this->updateStepEnabled) { $this->doCoreUpgrade(); // 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()]); } // post-upgrade repairs $repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher()); $repair->run(); //Invalidate update feed $this->config->setAppValue('core', 'lastupdatedat', 0); // 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'); } // only set the final version if everything went well $this->config->setSystemValue('version', implode('.', \OCP\Util::getVersion())); } }
public function testRunInstanceVerification() { $this->checker = $this->getMockBuilder('\\OC\\IntegrityCheck\\Checker')->setConstructorArgs([$this->environmentHelper, $this->fileAccessHelper, $this->appLocator, $this->config, $this->cacheFactory, $this->appManager])->setMethods(['verifyCoreSignature', 'verifyAppSignature'])->getMock(); $this->checker->expects($this->at(0))->method('verifyCoreSignature'); $this->appLocator->expects($this->at(0))->Method('getAllApps')->will($this->returnValue(['files', 'calendar', 'contacts', 'dav'])); $this->appManager->expects($this->at(0))->method('isShipped')->with('files')->will($this->returnValue(true)); $this->checker->expects($this->at(1))->method('verifyAppSignature')->with('files'); $this->appManager->expects($this->at(1))->method('isShipped')->with('calendar')->will($this->returnValue(false)); $this->appLocator->expects($this->at(1))->method('getAppPath')->with('calendar')->will($this->returnValue('/apps/calendar')); $this->fileAccessHelper->expects($this->at(0))->method('file_exists')->with('/apps/calendar/appinfo/signature.json')->will($this->returnValue(true)); $this->checker->expects($this->at(2))->method('verifyAppSignature')->with('calendar'); $this->appManager->expects($this->at(2))->method('isShipped')->with('contacts')->will($this->returnValue(false)); $this->appLocator->expects($this->at(2))->method('getAppPath')->with('contacts')->will($this->returnValue('/apps/contacts')); $this->fileAccessHelper->expects($this->at(1))->method('file_exists')->with('/apps/contacts/appinfo/signature.json')->will($this->returnValue(false)); $this->appManager->expects($this->at(3))->method('isShipped')->with('dav')->will($this->returnValue(true)); $this->checker->expects($this->at(3))->method('verifyAppSignature')->with('dav'); $this->checker->runInstanceVerification(); }
/** * @return RedirectResponse */ public function rescanFailedIntegrityCheck() { $this->checker->runInstanceVerification(); return new RedirectResponse($this->urlGenerator->linkToRoute('settings_admin')); }