Updater.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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\IConfig;
  60. use OCP\ILogger;
  61. use OCP\Util;
  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->getSystemValueString('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. $this->doUpgrade($currentVersion, $installedVersion);
  125. } catch (HintException $exception) {
  126. $this->log->error($exception->getMessage(), [
  127. 'exception' => $exception,
  128. ]);
  129. $this->emit('\OC\Updater', 'failure', [$exception->getMessage() . ': ' .$exception->getHint()]);
  130. $success = false;
  131. } catch (\Exception $exception) {
  132. $this->log->error($exception->getMessage(), [
  133. 'exception' => $exception,
  134. ]);
  135. $this->emit('\OC\Updater', 'failure', [get_class($exception) . ': ' .$exception->getMessage()]);
  136. $success = false;
  137. }
  138. $this->emit('\OC\Updater', 'updateEnd', [$success]);
  139. if (!$wasMaintenanceModeEnabled && $success) {
  140. $this->config->setSystemValue('maintenance', false);
  141. $this->emit('\OC\Updater', 'maintenanceDisabled');
  142. } else {
  143. $this->emit('\OC\Updater', 'maintenanceActive');
  144. }
  145. $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
  146. $this->config->setSystemValue('loglevel', $logLevel);
  147. $this->config->setSystemValue('installed', true);
  148. return $success;
  149. }
  150. /**
  151. * Return version from which this version is allowed to upgrade from
  152. *
  153. * @return array allowed previous versions per vendor
  154. */
  155. private function getAllowedPreviousVersions(): array {
  156. // this should really be a JSON file
  157. require \OC::$SERVERROOT . '/version.php';
  158. /** @var array $OC_VersionCanBeUpgradedFrom */
  159. return $OC_VersionCanBeUpgradedFrom;
  160. }
  161. /**
  162. * Return vendor from which this version was published
  163. *
  164. * @return string Get the vendor
  165. */
  166. private function getVendor(): string {
  167. // this should really be a JSON file
  168. require \OC::$SERVERROOT . '/version.php';
  169. /** @var string $vendor */
  170. return (string) $vendor;
  171. }
  172. /**
  173. * Whether an upgrade to a specified version is possible
  174. * @param string $oldVersion
  175. * @param string $newVersion
  176. * @param array $allowedPreviousVersions
  177. * @return bool
  178. */
  179. public function isUpgradePossible(string $oldVersion, string $newVersion, array $allowedPreviousVersions): bool {
  180. $version = explode('.', $oldVersion);
  181. $majorMinor = $version[0] . '.' . $version[1];
  182. $currentVendor = $this->config->getAppValue('core', 'vendor', '');
  183. // Vendor was not set correctly on install, so we have to white-list known versions
  184. if ($currentVendor === '' && (
  185. isset($allowedPreviousVersions['owncloud'][$oldVersion]) ||
  186. isset($allowedPreviousVersions['owncloud'][$majorMinor])
  187. )) {
  188. $currentVendor = 'owncloud';
  189. $this->config->setAppValue('core', 'vendor', $currentVendor);
  190. }
  191. if ($currentVendor === 'nextcloud') {
  192. return isset($allowedPreviousVersions[$currentVendor][$majorMinor])
  193. && (version_compare($oldVersion, $newVersion, '<=') ||
  194. $this->config->getSystemValueBool('debug', false));
  195. }
  196. // Check if the instance can be migrated
  197. return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) ||
  198. isset($allowedPreviousVersions[$currentVendor][$oldVersion]);
  199. }
  200. /**
  201. * runs the update actions in maintenance mode, does not upgrade the source files
  202. * except the main .htaccess file
  203. *
  204. * @param string $currentVersion current version to upgrade to
  205. * @param string $installedVersion previous version from which to upgrade from
  206. *
  207. * @throws \Exception
  208. */
  209. private function doUpgrade(string $currentVersion, string $installedVersion): void {
  210. // Stop update if the update is over several major versions
  211. $allowedPreviousVersions = $this->getAllowedPreviousVersions();
  212. if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
  213. throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
  214. }
  215. // Update .htaccess files
  216. try {
  217. Setup::updateHtaccess();
  218. Setup::protectDataDirectory();
  219. } catch (\Exception $e) {
  220. throw new \Exception($e->getMessage());
  221. }
  222. // create empty file in data dir, so we can later find
  223. // out that this is indeed an ownCloud data directory
  224. // (in case it didn't exist before)
  225. file_put_contents($this->config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
  226. // pre-upgrade repairs
  227. $repair = \OCP\Server::get(Repair::class);
  228. $repair->setRepairSteps(Repair::getBeforeUpgradeRepairSteps());
  229. $repair->run();
  230. $this->doCoreUpgrade();
  231. try {
  232. // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
  233. Setup::installBackgroundJobs();
  234. } catch (\Exception $e) {
  235. throw new \Exception($e->getMessage());
  236. }
  237. // update all shipped apps
  238. $this->checkAppsRequirements();
  239. $this->doAppUpgrade();
  240. // Update the appfetchers version so it downloads the correct list from the appstore
  241. \OC::$server->get(AppFetcher::class)->setVersion($currentVersion);
  242. /** @var AppManager $appManager */
  243. $appManager = \OC::$server->getAppManager();
  244. // upgrade appstore apps
  245. $this->upgradeAppStoreApps($appManager->getInstalledApps());
  246. $autoDisabledApps = $appManager->getAutoDisabledApps();
  247. if (!empty($autoDisabledApps)) {
  248. $this->upgradeAppStoreApps(array_keys($autoDisabledApps), $autoDisabledApps);
  249. }
  250. // install new shipped apps on upgrade
  251. $errors = Installer::installShippedApps(true);
  252. foreach ($errors as $appId => $exception) {
  253. /** @var \Exception $exception */
  254. $this->log->error($exception->getMessage(), [
  255. 'exception' => $exception,
  256. 'app' => $appId,
  257. ]);
  258. $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
  259. }
  260. // post-upgrade repairs
  261. $repair = \OCP\Server::get(Repair::class);
  262. $repair->setRepairSteps(Repair::getRepairSteps());
  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', 'extended_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, \OCP\Server::get(IAppManager::class)->getAppVersion($appId)]);
  315. \OC_App::updateApp($appId);
  316. $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OCP\Server::get(IAppManager::class)->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->getSystemValueString('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. }