Updater.php 20 KB

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