Updater.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. * @copyright Copyright (c) 2016, Lukas Reschke <lukas@statuscode.ch>
  6. *
  7. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  8. * @author Bjoern Schiessle <bjoern@schiessle.org>
  9. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  10. * @author Frank Karlitschek <frank@karlitschek.de>
  11. * @author Georg Ehrke <oc.list@georgehrke.com>
  12. * @author J0WI <J0WI@users.noreply.github.com>
  13. * @author Joas Schilling <coding@schilljs.com>
  14. * @author Julius Härtl <jus@bitgrid.net>
  15. * @author Lukas Reschke <lukas@statuscode.ch>
  16. * @author Morris Jobke <hey@morrisjobke.de>
  17. * @author Robin Appelman <robin@icewind.nl>
  18. * @author Roeland Jago Douma <roeland@famdouma.nl>
  19. * @author Steffen Lindner <mail@steffen-lindner.de>
  20. * @author Thomas Müller <thomas.mueller@tmit.eu>
  21. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  22. * @author Vincent Petry <vincent@nextcloud.com>
  23. *
  24. * @license AGPL-3.0
  25. *
  26. * This code is free software: you can redistribute it and/or modify
  27. * it under the terms of the GNU Affero General Public License, version 3,
  28. * as published by the Free Software Foundation.
  29. *
  30. * This program is distributed in the hope that it will be useful,
  31. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  32. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33. * GNU Affero General Public License for more details.
  34. *
  35. * You should have received a copy of the GNU Affero General Public License, version 3,
  36. * along with this program. If not, see <http://www.gnu.org/licenses/>
  37. *
  38. */
  39. namespace OC;
  40. use Composer\Semver\Semver;
  41. use OCP\App\IAppManager;
  42. use OCP\EventDispatcher\Event;
  43. use OCP\EventDispatcher\IEventDispatcher;
  44. use OCP\HintException;
  45. use OCP\IConfig;
  46. use OCP\ILogger;
  47. use OCP\Util;
  48. use OC\App\AppManager;
  49. use OC\DB\Connection;
  50. use OC\DB\MigrationService;
  51. use OC\DB\MigratorExecuteSqlEvent;
  52. use OC\Hooks\BasicEmitter;
  53. use OC\IntegrityCheck\Checker;
  54. use OC\Repair\Events\RepairAdvanceEvent;
  55. use OC\Repair\Events\RepairErrorEvent;
  56. use OC\Repair\Events\RepairFinishEvent;
  57. use OC\Repair\Events\RepairInfoEvent;
  58. use OC\Repair\Events\RepairStartEvent;
  59. use OC\Repair\Events\RepairStepEvent;
  60. use OC\Repair\Events\RepairWarningEvent;
  61. use OC_App;
  62. use Psr\Log\LoggerInterface;
  63. /**
  64. * Class that handles autoupdating of ownCloud
  65. *
  66. * Hooks provided in scope \OC\Updater
  67. * - maintenanceStart()
  68. * - maintenanceEnd()
  69. * - dbUpgrade()
  70. * - failure(string $message)
  71. */
  72. class Updater extends BasicEmitter {
  73. /** @var LoggerInterface */
  74. private $log;
  75. /** @var IConfig */
  76. private $config;
  77. /** @var Checker */
  78. private $checker;
  79. /** @var Installer */
  80. private $installer;
  81. private $logLevelNames = [
  82. 0 => 'Debug',
  83. 1 => 'Info',
  84. 2 => 'Warning',
  85. 3 => 'Error',
  86. 4 => 'Fatal',
  87. ];
  88. public function __construct(IConfig $config,
  89. Checker $checker,
  90. ?LoggerInterface $log,
  91. Installer $installer) {
  92. $this->log = $log;
  93. $this->config = $config;
  94. $this->checker = $checker;
  95. $this->installer = $installer;
  96. }
  97. /**
  98. * runs the update actions in maintenance mode, does not upgrade the source files
  99. * except the main .htaccess file
  100. *
  101. * @return bool true if the operation succeeded, false otherwise
  102. */
  103. public function upgrade(): bool {
  104. $this->logAllEvents();
  105. $logLevel = $this->config->getSystemValue('loglevel', ILogger::WARN);
  106. $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
  107. $this->config->setSystemValue('loglevel', ILogger::DEBUG);
  108. $wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
  109. if (!$wasMaintenanceModeEnabled) {
  110. $this->config->setSystemValue('maintenance', true);
  111. $this->emit('\OC\Updater', 'maintenanceEnabled');
  112. }
  113. // Clear CAN_INSTALL file if not on git
  114. if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) {
  115. if (!unlink(\OC::$configDir . '/CAN_INSTALL')) {
  116. $this->log->error('Could not cleanup CAN_INSTALL from your config folder. Please remove this file manually.');
  117. }
  118. }
  119. $installedVersion = $this->config->getSystemValue('version', '0.0.0');
  120. $currentVersion = implode('.', \OCP\Util::getVersion());
  121. $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, ['app' => 'core']);
  122. $success = true;
  123. try {
  124. if (PHP_INT_SIZE < 8 && Semver::satisfies($currentVersion, '> 25')) {
  125. throw new HintException('You are running a 32-bit PHP version. Cannot upgrade to Nextcloud 26 and higher. Please switch to 64-bit PHP.');
  126. }
  127. $this->doUpgrade($currentVersion, $installedVersion);
  128. } catch (HintException $exception) {
  129. $this->log->error($exception->getMessage(), [
  130. 'exception' => $exception,
  131. ]);
  132. $this->emit('\OC\Updater', 'failure', [$exception->getMessage() . ': ' .$exception->getHint()]);
  133. $success = false;
  134. } catch (\Exception $exception) {
  135. $this->log->error($exception->getMessage(), [
  136. 'exception' => $exception,
  137. ]);
  138. $this->emit('\OC\Updater', 'failure', [get_class($exception) . ': ' .$exception->getMessage()]);
  139. $success = false;
  140. }
  141. $this->emit('\OC\Updater', 'updateEnd', [$success]);
  142. if (!$wasMaintenanceModeEnabled && $success) {
  143. $this->config->setSystemValue('maintenance', false);
  144. $this->emit('\OC\Updater', 'maintenanceDisabled');
  145. } else {
  146. $this->emit('\OC\Updater', 'maintenanceActive');
  147. }
  148. $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
  149. $this->config->setSystemValue('loglevel', $logLevel);
  150. $this->config->setSystemValue('installed', true);
  151. return $success;
  152. }
  153. /**
  154. * Return version from which this version is allowed to upgrade from
  155. *
  156. * @return array allowed previous versions per vendor
  157. */
  158. private function getAllowedPreviousVersions(): array {
  159. // this should really be a JSON file
  160. require \OC::$SERVERROOT . '/version.php';
  161. /** @var array $OC_VersionCanBeUpgradedFrom */
  162. return $OC_VersionCanBeUpgradedFrom;
  163. }
  164. /**
  165. * Return vendor from which this version was published
  166. *
  167. * @return string Get the vendor
  168. */
  169. private function getVendor(): string {
  170. // this should really be a JSON file
  171. require \OC::$SERVERROOT . '/version.php';
  172. /** @var string $vendor */
  173. return (string) $vendor;
  174. }
  175. /**
  176. * Whether an upgrade to a specified version is possible
  177. * @param string $oldVersion
  178. * @param string $newVersion
  179. * @param array $allowedPreviousVersions
  180. * @return bool
  181. */
  182. public function isUpgradePossible(string $oldVersion, string $newVersion, array $allowedPreviousVersions): bool {
  183. $version = explode('.', $oldVersion);
  184. $majorMinor = $version[0] . '.' . $version[1];
  185. $currentVendor = $this->config->getAppValue('core', 'vendor', '');
  186. // Vendor was not set correctly on install, so we have to white-list known versions
  187. if ($currentVendor === '' && (
  188. isset($allowedPreviousVersions['owncloud'][$oldVersion]) ||
  189. isset($allowedPreviousVersions['owncloud'][$majorMinor])
  190. )) {
  191. $currentVendor = 'owncloud';
  192. $this->config->setAppValue('core', 'vendor', $currentVendor);
  193. }
  194. if ($currentVendor === 'nextcloud') {
  195. return isset($allowedPreviousVersions[$currentVendor][$majorMinor])
  196. && (version_compare($oldVersion, $newVersion, '<=') ||
  197. $this->config->getSystemValue('debug', false));
  198. }
  199. // Check if the instance can be migrated
  200. return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) ||
  201. isset($allowedPreviousVersions[$currentVendor][$oldVersion]);
  202. }
  203. /**
  204. * runs the update actions in maintenance mode, does not upgrade the source files
  205. * except the main .htaccess file
  206. *
  207. * @param string $currentVersion current version to upgrade to
  208. * @param string $installedVersion previous version from which to upgrade from
  209. *
  210. * @throws \Exception
  211. */
  212. private function doUpgrade(string $currentVersion, string $installedVersion): void {
  213. // Stop update if the update is over several major versions
  214. $allowedPreviousVersions = $this->getAllowedPreviousVersions();
  215. if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
  216. throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
  217. }
  218. // Update .htaccess files
  219. try {
  220. Setup::updateHtaccess();
  221. Setup::protectDataDirectory();
  222. } catch (\Exception $e) {
  223. throw new \Exception($e->getMessage());
  224. }
  225. // create empty file in data dir, so we can later find
  226. // out that this is indeed an ownCloud data directory
  227. // (in case it didn't exist before)
  228. file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
  229. // pre-upgrade repairs
  230. $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class), \OC::$server->get(LoggerInterface::class));
  231. $repair->run();
  232. $this->doCoreUpgrade();
  233. try {
  234. // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
  235. Setup::installBackgroundJobs();
  236. } catch (\Exception $e) {
  237. throw new \Exception($e->getMessage());
  238. }
  239. // update all shipped apps
  240. $this->checkAppsRequirements();
  241. $this->doAppUpgrade();
  242. // Update the appfetchers version so it downloads the correct list from the appstore
  243. \OC::$server->getAppFetcher()->setVersion($currentVersion);
  244. /** @var IAppManager|AppManager $appManager */
  245. $appManager = \OC::$server->getAppManager();
  246. // upgrade appstore apps
  247. $this->upgradeAppStoreApps($appManager->getInstalledApps());
  248. $autoDisabledApps = $appManager->getAutoDisabledApps();
  249. if (!empty($autoDisabledApps)) {
  250. $this->upgradeAppStoreApps(array_keys($autoDisabledApps), $autoDisabledApps);
  251. }
  252. // install new shipped apps on upgrade
  253. $errors = Installer::installShippedApps(true);
  254. foreach ($errors as $appId => $exception) {
  255. /** @var \Exception $exception */
  256. $this->log->error($exception->getMessage(), [
  257. 'exception' => $exception,
  258. 'app' => $appId,
  259. ]);
  260. $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
  261. }
  262. // post-upgrade repairs
  263. $repair = new Repair(Repair::getRepairSteps(), \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class), \OC::$server->get(LoggerInterface::class));
  264. $repair->run();
  265. //Invalidate update feed
  266. $this->config->setAppValue('core', 'lastupdatedat', '0');
  267. // Check for code integrity if not disabled
  268. if (\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) {
  269. $this->emit('\OC\Updater', 'startCheckCodeIntegrity');
  270. $this->checker->runInstanceVerification();
  271. $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity');
  272. }
  273. // only set the final version if everything went well
  274. $this->config->setSystemValue('version', implode('.', Util::getVersion()));
  275. $this->config->setAppValue('core', 'vendor', $this->getVendor());
  276. }
  277. protected function doCoreUpgrade(): void {
  278. $this->emit('\OC\Updater', 'dbUpgradeBefore');
  279. // execute core migrations
  280. $ms = new MigrationService('core', \OC::$server->get(Connection::class));
  281. $ms->migrate();
  282. $this->emit('\OC\Updater', 'dbUpgrade');
  283. }
  284. /**
  285. * upgrades all apps within a major ownCloud upgrade. Also loads "priority"
  286. * (types authentication, filesystem, logging, in that order) afterwards.
  287. *
  288. * @throws NeedsUpdateException
  289. */
  290. protected function doAppUpgrade(): void {
  291. $apps = \OC_App::getEnabledApps();
  292. $priorityTypes = ['authentication', 'filesystem', 'logging'];
  293. $pseudoOtherType = 'other';
  294. $stacks = [$pseudoOtherType => []];
  295. foreach ($apps as $appId) {
  296. $priorityType = false;
  297. foreach ($priorityTypes as $type) {
  298. if (!isset($stacks[$type])) {
  299. $stacks[$type] = [];
  300. }
  301. if (\OC_App::isType($appId, [$type])) {
  302. $stacks[$type][] = $appId;
  303. $priorityType = true;
  304. break;
  305. }
  306. }
  307. if (!$priorityType) {
  308. $stacks[$pseudoOtherType][] = $appId;
  309. }
  310. }
  311. foreach (array_merge($priorityTypes, [$pseudoOtherType]) as $type) {
  312. $stack = $stacks[$type];
  313. foreach ($stack as $appId) {
  314. if (\OC_App::shouldUpgrade($appId)) {
  315. $this->emit('\OC\Updater', 'appUpgradeStarted', [$appId, \OC_App::getAppVersion($appId)]);
  316. \OC_App::updateApp($appId);
  317. $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]);
  318. }
  319. if ($type !== $pseudoOtherType) {
  320. // load authentication, filesystem and logging apps after
  321. // upgrading them. Other apps my need to rely on modifying
  322. // user and/or filesystem aspects.
  323. \OC_App::loadApp($appId);
  324. }
  325. }
  326. }
  327. }
  328. /**
  329. * check if the current enabled apps are compatible with the current
  330. * ownCloud version. disable them if not.
  331. * This is important if you upgrade ownCloud and have non ported 3rd
  332. * party apps installed.
  333. *
  334. * @throws \Exception
  335. */
  336. private function checkAppsRequirements(): void {
  337. $isCoreUpgrade = $this->isCodeUpgrade();
  338. $apps = OC_App::getEnabledApps();
  339. $version = implode('.', Util::getVersion());
  340. $appManager = \OC::$server->getAppManager();
  341. foreach ($apps as $app) {
  342. // check if the app is compatible with this version of Nextcloud
  343. $info = $appManager->getAppInfo($app);
  344. if ($info === null || !OC_App::isAppCompatible($version, $info)) {
  345. if ($appManager->isShipped($app)) {
  346. throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update');
  347. }
  348. $appManager->disableApp($app, true);
  349. $this->emit('\OC\Updater', 'incompatibleAppDisabled', [$app]);
  350. }
  351. }
  352. }
  353. /**
  354. * @return bool
  355. */
  356. private function isCodeUpgrade(): bool {
  357. $installedVersion = $this->config->getSystemValue('version', '0.0.0');
  358. $currentVersion = implode('.', Util::getVersion());
  359. if (version_compare($currentVersion, $installedVersion, '>')) {
  360. return true;
  361. }
  362. return false;
  363. }
  364. /**
  365. * @param array $apps
  366. * @param array $previousEnableStates
  367. * @throws \Exception
  368. */
  369. private function upgradeAppStoreApps(array $apps, array $previousEnableStates = []): void {
  370. foreach ($apps as $app) {
  371. try {
  372. $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
  373. if ($this->installer->isUpdateAvailable($app)) {
  374. $this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]);
  375. $this->installer->updateAppstoreApp($app);
  376. }
  377. $this->emit('\OC\Updater', 'checkAppStoreApp', [$app]);
  378. if (!empty($previousEnableStates)) {
  379. $ocApp = new \OC_App();
  380. if (!empty($previousEnableStates[$app]) && is_array($previousEnableStates[$app])) {
  381. $ocApp->enable($app, $previousEnableStates[$app]);
  382. } else {
  383. $ocApp->enable($app);
  384. }
  385. }
  386. } catch (\Exception $ex) {
  387. $this->log->error($ex->getMessage(), [
  388. 'exception' => $ex,
  389. ]);
  390. }
  391. }
  392. }
  393. private function logAllEvents(): void {
  394. $log = $this->log;
  395. /** @var IEventDispatcher $dispatcher */
  396. $dispatcher = \OC::$server->get(IEventDispatcher::class);
  397. $dispatcher->addListener(
  398. MigratorExecuteSqlEvent::class,
  399. function (MigratorExecuteSqlEvent $event) use ($log): void {
  400. $log->info(get_class($event).': ' . $event->getSql() . ' (' . $event->getCurrentStep() . ' of ' . $event->getMaxStep() . ')', ['app' => 'updater']);
  401. }
  402. );
  403. $repairListener = function (Event $event) use ($log): void {
  404. if ($event instanceof RepairStartEvent) {
  405. $log->info(get_class($event).': Starting ... ' . $event->getMaxStep() . ' (' . $event->getCurrentStepName() . ')', ['app' => 'updater']);
  406. } elseif ($event instanceof RepairAdvanceEvent) {
  407. $desc = $event->getDescription();
  408. if (empty($desc)) {
  409. $desc = '';
  410. }
  411. $log->info(get_class($event).': ' . $desc . ' (' . $event->getIncrement() . ')', ['app' => 'updater']);
  412. } elseif ($event instanceof RepairFinishEvent) {
  413. $log->info(get_class($event), ['app' => 'updater']);
  414. } elseif ($event instanceof RepairStepEvent) {
  415. $log->info(get_class($event).': Repair step: ' . $event->getStepName(), ['app' => 'updater']);
  416. } elseif ($event instanceof RepairInfoEvent) {
  417. $log->info(get_class($event).': Repair info: ' . $event->getMessage(), ['app' => 'updater']);
  418. } elseif ($event instanceof RepairWarningEvent) {
  419. $log->warning(get_class($event).': Repair warning: ' . $event->getMessage(), ['app' => 'updater']);
  420. } elseif ($event instanceof RepairErrorEvent) {
  421. $log->error(get_class($event).': Repair error: ' . $event->getMessage(), ['app' => 'updater']);
  422. }
  423. };
  424. $dispatcher->addListener(RepairStartEvent::class, $repairListener);
  425. $dispatcher->addListener(RepairAdvanceEvent::class, $repairListener);
  426. $dispatcher->addListener(RepairFinishEvent::class, $repairListener);
  427. $dispatcher->addListener(RepairStepEvent::class, $repairListener);
  428. $dispatcher->addListener(RepairInfoEvent::class, $repairListener);
  429. $dispatcher->addListener(RepairWarningEvent::class, $repairListener);
  430. $dispatcher->addListener(RepairErrorEvent::class, $repairListener);
  431. $this->listen('\OC\Updater', 'maintenanceEnabled', function () use ($log) {
  432. $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']);
  433. });
  434. $this->listen('\OC\Updater', 'maintenanceDisabled', function () use ($log) {
  435. $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']);
  436. });
  437. $this->listen('\OC\Updater', 'maintenanceActive', function () use ($log) {
  438. $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']);
  439. });
  440. $this->listen('\OC\Updater', 'updateEnd', function ($success) use ($log) {
  441. if ($success) {
  442. $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']);
  443. } else {
  444. $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']);
  445. }
  446. });
  447. $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($log) {
  448. $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']);
  449. });
  450. $this->listen('\OC\Updater', 'dbUpgrade', function () use ($log) {
  451. $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']);
  452. });
  453. $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($log) {
  454. $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']);
  455. });
  456. $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($log) {
  457. $log->debug('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']);
  458. });
  459. $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($log) {
  460. $log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']);
  461. });
  462. $this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($log) {
  463. $log->debug('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']);
  464. });
  465. $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) {
  466. $log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <' . $app . '> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']);
  467. });
  468. $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) {
  469. $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']);
  470. });
  471. $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) {
  472. $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']);
  473. });
  474. $this->listen('\OC\Updater', 'failure', function ($message) use ($log) {
  475. $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']);
  476. });
  477. $this->listen('\OC\Updater', 'setDebugLogLevel', function () use ($log) {
  478. $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']);
  479. });
  480. $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($log) {
  481. $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']);
  482. });
  483. $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($log) {
  484. $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']);
  485. });
  486. $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($log) {
  487. $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']);
  488. });
  489. }
  490. }