You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Updater.php 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. * @copyright Copyright (c) 2016, Lukas Reschke <lukas@statuscode.ch>
  5. *
  6. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  7. * @author Bjoern Schiessle <bjoern@schiessle.org>
  8. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  9. * @author Frank Karlitschek <frank@karlitschek.de>
  10. * @author Georg Ehrke <oc.list@georgehrke.com>
  11. * @author Joas Schilling <coding@schilljs.com>
  12. * @author Julius Härtl <jus@bitgrid.net>
  13. * @author Lukas Reschke <lukas@statuscode.ch>
  14. * @author Morris Jobke <hey@morrisjobke.de>
  15. * @author Robin Appelman <robin@icewind.nl>
  16. * @author Roeland Jago Douma <roeland@famdouma.nl>
  17. * @author Steffen Lindner <mail@steffen-lindner.de>
  18. * @author Thomas Müller <thomas.mueller@tmit.eu>
  19. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  20. * @author Vincent Petry <vincent@nextcloud.com>
  21. *
  22. * @license AGPL-3.0
  23. *
  24. * This code is free software: you can redistribute it and/or modify
  25. * it under the terms of the GNU Affero General Public License, version 3,
  26. * as published by the Free Software Foundation.
  27. *
  28. * This program is distributed in the hope that it will be useful,
  29. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  30. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  31. * GNU Affero General Public License for more details.
  32. *
  33. * You should have received a copy of the GNU Affero General Public License, version 3,
  34. * along with this program. If not, see <http://www.gnu.org/licenses/>
  35. *
  36. */
  37. namespace OC;
  38. use OC\DB\MigrationService;
  39. use OC\Hooks\BasicEmitter;
  40. use OC\IntegrityCheck\Checker;
  41. use OC_App;
  42. use OCP\IConfig;
  43. use OCP\ILogger;
  44. use OCP\Util;
  45. use Symfony\Component\EventDispatcher\GenericEvent;
  46. /**
  47. * Class that handles autoupdating of ownCloud
  48. *
  49. * Hooks provided in scope \OC\Updater
  50. * - maintenanceStart()
  51. * - maintenanceEnd()
  52. * - dbUpgrade()
  53. * - failure(string $message)
  54. */
  55. class Updater extends BasicEmitter {
  56. /** @var ILogger $log */
  57. private $log;
  58. /** @var IConfig */
  59. private $config;
  60. /** @var Checker */
  61. private $checker;
  62. /** @var Installer */
  63. private $installer;
  64. private $logLevelNames = [
  65. 0 => 'Debug',
  66. 1 => 'Info',
  67. 2 => 'Warning',
  68. 3 => 'Error',
  69. 4 => 'Fatal',
  70. ];
  71. /**
  72. * @param IConfig $config
  73. * @param Checker $checker
  74. * @param ILogger $log
  75. * @param Installer $installer
  76. */
  77. public function __construct(IConfig $config,
  78. Checker $checker,
  79. ILogger $log = null,
  80. Installer $installer) {
  81. $this->log = $log;
  82. $this->config = $config;
  83. $this->checker = $checker;
  84. $this->installer = $installer;
  85. }
  86. /**
  87. * runs the update actions in maintenance mode, does not upgrade the source files
  88. * except the main .htaccess file
  89. *
  90. * @return bool true if the operation succeeded, false otherwise
  91. */
  92. public function upgrade() {
  93. $this->emitRepairEvents();
  94. $this->logAllEvents();
  95. $logLevel = $this->config->getSystemValue('loglevel', ILogger::WARN);
  96. $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
  97. $this->config->setSystemValue('loglevel', ILogger::DEBUG);
  98. $wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
  99. if (!$wasMaintenanceModeEnabled) {
  100. $this->config->setSystemValue('maintenance', true);
  101. $this->emit('\OC\Updater', 'maintenanceEnabled');
  102. }
  103. // Clear CAN_INSTALL file if not on git
  104. if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) {
  105. if (!unlink(\OC::$configDir . '/CAN_INSTALL')) {
  106. $this->log->error('Could not cleanup CAN_INSTALL from your config folder. Please remove this file manually.');
  107. }
  108. }
  109. $installedVersion = $this->config->getSystemValue('version', '0.0.0');
  110. $currentVersion = implode('.', \OCP\Util::getVersion());
  111. $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, ['app' => 'core']);
  112. $success = true;
  113. try {
  114. $this->doUpgrade($currentVersion, $installedVersion);
  115. } catch (HintException $exception) {
  116. $this->log->logException($exception, ['app' => 'core']);
  117. $this->emit('\OC\Updater', 'failure', [$exception->getMessage() . ': ' .$exception->getHint()]);
  118. $success = false;
  119. } catch (\Exception $exception) {
  120. $this->log->logException($exception, ['app' => 'core']);
  121. $this->emit('\OC\Updater', 'failure', [get_class($exception) . ': ' .$exception->getMessage()]);
  122. $success = false;
  123. }
  124. $this->emit('\OC\Updater', 'updateEnd', [$success]);
  125. if (!$wasMaintenanceModeEnabled && $success) {
  126. $this->config->setSystemValue('maintenance', false);
  127. $this->emit('\OC\Updater', 'maintenanceDisabled');
  128. } else {
  129. $this->emit('\OC\Updater', 'maintenanceActive');
  130. }
  131. $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
  132. $this->config->setSystemValue('loglevel', $logLevel);
  133. $this->config->setSystemValue('installed', true);
  134. return $success;
  135. }
  136. /**
  137. * Return version from which this version is allowed to upgrade from
  138. *
  139. * @return array allowed previous versions per vendor
  140. */
  141. private function getAllowedPreviousVersions() {
  142. // this should really be a JSON file
  143. require \OC::$SERVERROOT . '/version.php';
  144. /** @var array $OC_VersionCanBeUpgradedFrom */
  145. return $OC_VersionCanBeUpgradedFrom;
  146. }
  147. /**
  148. * Return vendor from which this version was published
  149. *
  150. * @return string Get the vendor
  151. */
  152. private function getVendor() {
  153. // this should really be a JSON file
  154. require \OC::$SERVERROOT . '/version.php';
  155. /** @var string $vendor */
  156. return (string) $vendor;
  157. }
  158. /**
  159. * Whether an upgrade to a specified version is possible
  160. * @param string $oldVersion
  161. * @param string $newVersion
  162. * @param array $allowedPreviousVersions
  163. * @return bool
  164. */
  165. public function isUpgradePossible($oldVersion, $newVersion, array $allowedPreviousVersions) {
  166. $version = explode('.', $oldVersion);
  167. $majorMinor = $version[0] . '.' . $version[1];
  168. $currentVendor = $this->config->getAppValue('core', 'vendor', '');
  169. // Vendor was not set correctly on install, so we have to white-list known versions
  170. if ($currentVendor === '' && (
  171. isset($allowedPreviousVersions['owncloud'][$oldVersion]) ||
  172. isset($allowedPreviousVersions['owncloud'][$majorMinor])
  173. )) {
  174. $currentVendor = 'owncloud';
  175. $this->config->setAppValue('core', 'vendor', $currentVendor);
  176. }
  177. if ($currentVendor === 'nextcloud') {
  178. return isset($allowedPreviousVersions[$currentVendor][$majorMinor])
  179. && (version_compare($oldVersion, $newVersion, '<=') ||
  180. $this->config->getSystemValue('debug', false));
  181. }
  182. // Check if the instance can be migrated
  183. return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) ||
  184. isset($allowedPreviousVersions[$currentVendor][$oldVersion]);
  185. }
  186. /**
  187. * runs the update actions in maintenance mode, does not upgrade the source files
  188. * except the main .htaccess file
  189. *
  190. * @param string $currentVersion current version to upgrade to
  191. * @param string $installedVersion previous version from which to upgrade from
  192. *
  193. * @throws \Exception
  194. */
  195. private function doUpgrade($currentVersion, $installedVersion) {
  196. // Stop update if the update is over several major versions
  197. $allowedPreviousVersions = $this->getAllowedPreviousVersions();
  198. if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
  199. throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
  200. }
  201. // Update .htaccess files
  202. try {
  203. Setup::updateHtaccess();
  204. Setup::protectDataDirectory();
  205. } catch (\Exception $e) {
  206. throw new \Exception($e->getMessage());
  207. }
  208. // create empty file in data dir, so we can later find
  209. // out that this is indeed an ownCloud data directory
  210. // (in case it didn't exist before)
  211. file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
  212. // pre-upgrade repairs
  213. $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher());
  214. $repair->run();
  215. $this->doCoreUpgrade();
  216. try {
  217. // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
  218. Setup::installBackgroundJobs();
  219. } catch (\Exception $e) {
  220. throw new \Exception($e->getMessage());
  221. }
  222. // update all shipped apps
  223. $this->checkAppsRequirements();
  224. $this->doAppUpgrade();
  225. // Update the appfetchers version so it downloads the correct list from the appstore
  226. \OC::$server->getAppFetcher()->setVersion($currentVersion);
  227. // upgrade appstore apps
  228. $this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps());
  229. $autoDisabledApps = \OC::$server->getAppManager()->getAutoDisabledApps();
  230. $this->upgradeAppStoreApps($autoDisabledApps, true);
  231. // install new shipped apps on upgrade
  232. OC_App::loadApps(['authentication']);
  233. $errors = Installer::installShippedApps(true);
  234. foreach ($errors as $appId => $exception) {
  235. /** @var \Exception $exception */
  236. $this->log->logException($exception, ['app' => $appId]);
  237. $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
  238. }
  239. // post-upgrade repairs
  240. $repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher());
  241. $repair->run();
  242. //Invalidate update feed
  243. $this->config->setAppValue('core', 'lastupdatedat', 0);
  244. // Check for code integrity if not disabled
  245. if (\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) {
  246. $this->emit('\OC\Updater', 'startCheckCodeIntegrity');
  247. $this->checker->runInstanceVerification();
  248. $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity');
  249. }
  250. // only set the final version if everything went well
  251. $this->config->setSystemValue('version', implode('.', Util::getVersion()));
  252. $this->config->setAppValue('core', 'vendor', $this->getVendor());
  253. }
  254. protected function doCoreUpgrade() {
  255. $this->emit('\OC\Updater', 'dbUpgradeBefore');
  256. // execute core migrations
  257. $ms = new MigrationService('core', \OC::$server->getDatabaseConnection());
  258. $ms->migrate();
  259. $this->emit('\OC\Updater', 'dbUpgrade');
  260. }
  261. /**
  262. * upgrades all apps within a major ownCloud upgrade. Also loads "priority"
  263. * (types authentication, filesystem, logging, in that order) afterwards.
  264. *
  265. * @throws NeedsUpdateException
  266. */
  267. protected function doAppUpgrade() {
  268. $apps = \OC_App::getEnabledApps();
  269. $priorityTypes = ['authentication', 'filesystem', 'logging'];
  270. $pseudoOtherType = 'other';
  271. $stacks = [$pseudoOtherType => []];
  272. foreach ($apps as $appId) {
  273. $priorityType = false;
  274. foreach ($priorityTypes as $type) {
  275. if (!isset($stacks[$type])) {
  276. $stacks[$type] = [];
  277. }
  278. if (\OC_App::isType($appId, [$type])) {
  279. $stacks[$type][] = $appId;
  280. $priorityType = true;
  281. break;
  282. }
  283. }
  284. if (!$priorityType) {
  285. $stacks[$pseudoOtherType][] = $appId;
  286. }
  287. }
  288. foreach ($stacks as $type => $stack) {
  289. foreach ($stack as $appId) {
  290. if (\OC_App::shouldUpgrade($appId)) {
  291. $this->emit('\OC\Updater', 'appUpgradeStarted', [$appId, \OC_App::getAppVersion($appId)]);
  292. \OC_App::updateApp($appId);
  293. $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]);
  294. }
  295. if ($type !== $pseudoOtherType) {
  296. // load authentication, filesystem and logging apps after
  297. // upgrading them. Other apps my need to rely on modifying
  298. // user and/or filesystem aspects.
  299. \OC_App::loadApp($appId);
  300. }
  301. }
  302. }
  303. }
  304. /**
  305. * check if the current enabled apps are compatible with the current
  306. * ownCloud version. disable them if not.
  307. * This is important if you upgrade ownCloud and have non ported 3rd
  308. * party apps installed.
  309. *
  310. * @return array
  311. * @throws \Exception
  312. */
  313. private function checkAppsRequirements() {
  314. $isCoreUpgrade = $this->isCodeUpgrade();
  315. $apps = OC_App::getEnabledApps();
  316. $version = implode('.', Util::getVersion());
  317. $disabledApps = [];
  318. $appManager = \OC::$server->getAppManager();
  319. foreach ($apps as $app) {
  320. // check if the app is compatible with this version of Nextcloud
  321. $info = OC_App::getAppInfo($app);
  322. if ($info === null || !OC_App::isAppCompatible($version, $info)) {
  323. if ($appManager->isShipped($app)) {
  324. throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update');
  325. }
  326. \OC::$server->getAppManager()->disableApp($app, true);
  327. $this->emit('\OC\Updater', 'incompatibleAppDisabled', [$app]);
  328. }
  329. // no need to disable any app in case this is a non-core upgrade
  330. if (!$isCoreUpgrade) {
  331. continue;
  332. }
  333. // shipped apps will remain enabled
  334. if ($appManager->isShipped($app)) {
  335. continue;
  336. }
  337. // authentication and session apps will remain enabled as well
  338. if (OC_App::isType($app, ['session', 'authentication'])) {
  339. continue;
  340. }
  341. }
  342. return $disabledApps;
  343. }
  344. /**
  345. * @return bool
  346. */
  347. private function isCodeUpgrade() {
  348. $installedVersion = $this->config->getSystemValue('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 $disabledApps
  357. * @param bool $reenable
  358. * @throws \Exception
  359. */
  360. private function upgradeAppStoreApps(array $disabledApps, $reenable = false) {
  361. foreach ($disabledApps 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 ($reenable) {
  370. $ocApp = new \OC_App();
  371. $ocApp->enable($app);
  372. }
  373. } catch (\Exception $ex) {
  374. $this->log->logException($ex, ['app' => 'core']);
  375. }
  376. }
  377. }
  378. /**
  379. * Forward messages emitted by the repair routine
  380. */
  381. private function emitRepairEvents() {
  382. $dispatcher = \OC::$server->getEventDispatcher();
  383. $dispatcher->addListener('\OC\Repair::warning', function ($event) {
  384. if ($event instanceof GenericEvent) {
  385. $this->emit('\OC\Updater', 'repairWarning', $event->getArguments());
  386. }
  387. });
  388. $dispatcher->addListener('\OC\Repair::error', function ($event) {
  389. if ($event instanceof GenericEvent) {
  390. $this->emit('\OC\Updater', 'repairError', $event->getArguments());
  391. }
  392. });
  393. $dispatcher->addListener('\OC\Repair::info', function ($event) {
  394. if ($event instanceof GenericEvent) {
  395. $this->emit('\OC\Updater', 'repairInfo', $event->getArguments());
  396. }
  397. });
  398. $dispatcher->addListener('\OC\Repair::step', function ($event) {
  399. if ($event instanceof GenericEvent) {
  400. $this->emit('\OC\Updater', 'repairStep', $event->getArguments());
  401. }
  402. });
  403. }
  404. private function logAllEvents() {
  405. $log = $this->log;
  406. $dispatcher = \OC::$server->getEventDispatcher();
  407. $dispatcher->addListener('\OC\DB\Migrator::executeSql', function ($event) use ($log) {
  408. if (!$event instanceof GenericEvent) {
  409. return;
  410. }
  411. $log->info('\OC\DB\Migrator::executeSql: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
  412. });
  413. $dispatcher->addListener('\OC\DB\Migrator::checkTable', function ($event) use ($log) {
  414. if (!$event instanceof GenericEvent) {
  415. return;
  416. }
  417. $log->info('\OC\DB\Migrator::checkTable: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
  418. });
  419. $repairListener = function ($event) use ($log) {
  420. if (!$event instanceof GenericEvent) {
  421. return;
  422. }
  423. switch ($event->getSubject()) {
  424. case '\OC\Repair::startProgress':
  425. $log->info('\OC\Repair::startProgress: Starting ... ' . $event->getArgument(1) . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
  426. break;
  427. case '\OC\Repair::advance':
  428. $desc = $event->getArgument(1);
  429. if (empty($desc)) {
  430. $desc = '';
  431. }
  432. $log->info('\OC\Repair::advance: ' . $desc . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
  433. break;
  434. case '\OC\Repair::finishProgress':
  435. $log->info('\OC\Repair::finishProgress', ['app' => 'updater']);
  436. break;
  437. case '\OC\Repair::step':
  438. $log->info('\OC\Repair::step: Repair step: ' . $event->getArgument(0), ['app' => 'updater']);
  439. break;
  440. case '\OC\Repair::info':
  441. $log->info('\OC\Repair::info: Repair info: ' . $event->getArgument(0), ['app' => 'updater']);
  442. break;
  443. case '\OC\Repair::warning':
  444. $log->warning('\OC\Repair::warning: Repair warning: ' . $event->getArgument(0), ['app' => 'updater']);
  445. break;
  446. case '\OC\Repair::error':
  447. $log->error('\OC\Repair::error: Repair error: ' . $event->getArgument(0), ['app' => 'updater']);
  448. break;
  449. }
  450. };
  451. $dispatcher->addListener('\OC\Repair::startProgress', $repairListener);
  452. $dispatcher->addListener('\OC\Repair::advance', $repairListener);
  453. $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener);
  454. $dispatcher->addListener('\OC\Repair::step', $repairListener);
  455. $dispatcher->addListener('\OC\Repair::info', $repairListener);
  456. $dispatcher->addListener('\OC\Repair::warning', $repairListener);
  457. $dispatcher->addListener('\OC\Repair::error', $repairListener);
  458. $this->listen('\OC\Updater', 'maintenanceEnabled', function () use ($log) {
  459. $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']);
  460. });
  461. $this->listen('\OC\Updater', 'maintenanceDisabled', function () use ($log) {
  462. $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']);
  463. });
  464. $this->listen('\OC\Updater', 'maintenanceActive', function () use ($log) {
  465. $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']);
  466. });
  467. $this->listen('\OC\Updater', 'updateEnd', function ($success) use ($log) {
  468. if ($success) {
  469. $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']);
  470. } else {
  471. $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']);
  472. }
  473. });
  474. $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($log) {
  475. $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']);
  476. });
  477. $this->listen('\OC\Updater', 'dbUpgrade', function () use ($log) {
  478. $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']);
  479. });
  480. $this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($log) {
  481. $log->info('\OC\Updater::dbSimulateUpgradeBefore: Checking whether the database schema can be updated (this can take a long time depending on the database size)', ['app' => 'updater']);
  482. });
  483. $this->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($log) {
  484. $log->info('\OC\Updater::dbSimulateUpgrade: Checked database schema update', ['app' => 'updater']);
  485. });
  486. $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($log) {
  487. $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']);
  488. });
  489. $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($log) {
  490. $log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']);
  491. });
  492. $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($log) {
  493. $log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']);
  494. });
  495. $this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($log) {
  496. $log->info('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']);
  497. });
  498. $this->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($log) {
  499. $log->info('\OC\Updater::appUpgradeCheckBefore: Checking updates of apps', ['app' => 'updater']);
  500. });
  501. $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) {
  502. $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']);
  503. });
  504. $this->listen('\OC\Updater', 'appUpgradeCheck', function () use ($log) {
  505. $log->info('\OC\Updater::appUpgradeCheck: Checked database schema update for apps', ['app' => 'updater']);
  506. });
  507. $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) {
  508. $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']);
  509. });
  510. $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) {
  511. $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']);
  512. });
  513. $this->listen('\OC\Updater', 'failure', function ($message) use ($log) {
  514. $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']);
  515. });
  516. $this->listen('\OC\Updater', 'setDebugLogLevel', function () use ($log) {
  517. $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']);
  518. });
  519. $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($log) {
  520. $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']);
  521. });
  522. $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($log) {
  523. $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']);
  524. });
  525. $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($log) {
  526. $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']);
  527. });
  528. }
  529. }