Updater.php 20 KB

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