1
0

Updater.php 20 KB

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