Updater.php 20 KB

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