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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  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\Connection;
  39. use OC\DB\MigrationService;
  40. use OC\Hooks\BasicEmitter;
  41. use OC\IntegrityCheck\Checker;
  42. use OC_App;
  43. use OCP\IConfig;
  44. use OCP\ILogger;
  45. use OCP\Util;
  46. use Symfony\Component\EventDispatcher\GenericEvent;
  47. /**
  48. * Class that handles autoupdating of ownCloud
  49. *
  50. * Hooks provided in scope \OC\Updater
  51. * - maintenanceStart()
  52. * - maintenanceEnd()
  53. * - dbUpgrade()
  54. * - failure(string $message)
  55. */
  56. class Updater extends BasicEmitter {
  57. /** @var ILogger $log */
  58. private $log;
  59. /** @var IConfig */
  60. private $config;
  61. /** @var Checker */
  62. private $checker;
  63. /** @var Installer */
  64. private $installer;
  65. private $logLevelNames = [
  66. 0 => 'Debug',
  67. 1 => 'Info',
  68. 2 => 'Warning',
  69. 3 => 'Error',
  70. 4 => 'Fatal',
  71. ];
  72. /**
  73. * @param IConfig $config
  74. * @param Checker $checker
  75. * @param ILogger $log
  76. * @param Installer $installer
  77. */
  78. public function __construct(IConfig $config,
  79. Checker $checker,
  80. ILogger $log = null,
  81. Installer $installer) {
  82. $this->log = $log;
  83. $this->config = $config;
  84. $this->checker = $checker;
  85. $this->installer = $installer;
  86. }
  87. /**
  88. * runs the update actions in maintenance mode, does not upgrade the source files
  89. * except the main .htaccess file
  90. *
  91. * @return bool true if the operation succeeded, false otherwise
  92. */
  93. public function upgrade() {
  94. $this->emitRepairEvents();
  95. $this->logAllEvents();
  96. $logLevel = $this->config->getSystemValue('loglevel', ILogger::WARN);
  97. $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
  98. $this->config->setSystemValue('loglevel', ILogger::DEBUG);
  99. $wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
  100. if (!$wasMaintenanceModeEnabled) {
  101. $this->config->setSystemValue('maintenance', true);
  102. $this->emit('\OC\Updater', 'maintenanceEnabled');
  103. }
  104. // Clear CAN_INSTALL file if not on git
  105. if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) {
  106. if (!unlink(\OC::$configDir . '/CAN_INSTALL')) {
  107. $this->log->error('Could not cleanup CAN_INSTALL from your config folder. Please remove this file manually.');
  108. }
  109. }
  110. $installedVersion = $this->config->getSystemValue('version', '0.0.0');
  111. $currentVersion = implode('.', \OCP\Util::getVersion());
  112. $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, ['app' => 'core']);
  113. $success = true;
  114. try {
  115. $this->doUpgrade($currentVersion, $installedVersion);
  116. } catch (HintException $exception) {
  117. $this->log->logException($exception, ['app' => 'core']);
  118. $this->emit('\OC\Updater', 'failure', [$exception->getMessage() . ': ' .$exception->getHint()]);
  119. $success = false;
  120. } catch (\Exception $exception) {
  121. $this->log->logException($exception, ['app' => 'core']);
  122. $this->emit('\OC\Updater', 'failure', [get_class($exception) . ': ' .$exception->getMessage()]);
  123. $success = false;
  124. }
  125. $this->emit('\OC\Updater', 'updateEnd', [$success]);
  126. if (!$wasMaintenanceModeEnabled && $success) {
  127. $this->config->setSystemValue('maintenance', false);
  128. $this->emit('\OC\Updater', 'maintenanceDisabled');
  129. } else {
  130. $this->emit('\OC\Updater', 'maintenanceActive');
  131. }
  132. $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
  133. $this->config->setSystemValue('loglevel', $logLevel);
  134. $this->config->setSystemValue('installed', true);
  135. return $success;
  136. }
  137. /**
  138. * Return version from which this version is allowed to upgrade from
  139. *
  140. * @return array allowed previous versions per vendor
  141. */
  142. private function getAllowedPreviousVersions() {
  143. // this should really be a JSON file
  144. require \OC::$SERVERROOT . '/version.php';
  145. /** @var array $OC_VersionCanBeUpgradedFrom */
  146. return $OC_VersionCanBeUpgradedFrom;
  147. }
  148. /**
  149. * Return vendor from which this version was published
  150. *
  151. * @return string Get the vendor
  152. */
  153. private function getVendor() {
  154. // this should really be a JSON file
  155. require \OC::$SERVERROOT . '/version.php';
  156. /** @var string $vendor */
  157. return (string) $vendor;
  158. }
  159. /**
  160. * Whether an upgrade to a specified version is possible
  161. * @param string $oldVersion
  162. * @param string $newVersion
  163. * @param array $allowedPreviousVersions
  164. * @return bool
  165. */
  166. public function isUpgradePossible($oldVersion, $newVersion, array $allowedPreviousVersions) {
  167. $version = explode('.', $oldVersion);
  168. $majorMinor = $version[0] . '.' . $version[1];
  169. $currentVendor = $this->config->getAppValue('core', 'vendor', '');
  170. // Vendor was not set correctly on install, so we have to white-list known versions
  171. if ($currentVendor === '' && (
  172. isset($allowedPreviousVersions['owncloud'][$oldVersion]) ||
  173. isset($allowedPreviousVersions['owncloud'][$majorMinor])
  174. )) {
  175. $currentVendor = 'owncloud';
  176. $this->config->setAppValue('core', 'vendor', $currentVendor);
  177. }
  178. if ($currentVendor === 'nextcloud') {
  179. return isset($allowedPreviousVersions[$currentVendor][$majorMinor])
  180. && (version_compare($oldVersion, $newVersion, '<=') ||
  181. $this->config->getSystemValue('debug', false));
  182. }
  183. // Check if the instance can be migrated
  184. return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) ||
  185. isset($allowedPreviousVersions[$currentVendor][$oldVersion]);
  186. }
  187. /**
  188. * runs the update actions in maintenance mode, does not upgrade the source files
  189. * except the main .htaccess file
  190. *
  191. * @param string $currentVersion current version to upgrade to
  192. * @param string $installedVersion previous version from which to upgrade from
  193. *
  194. * @throws \Exception
  195. */
  196. private function doUpgrade($currentVersion, $installedVersion) {
  197. // Stop update if the update is over several major versions
  198. $allowedPreviousVersions = $this->getAllowedPreviousVersions();
  199. if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
  200. throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
  201. }
  202. // Update .htaccess files
  203. try {
  204. Setup::updateHtaccess();
  205. Setup::protectDataDirectory();
  206. } catch (\Exception $e) {
  207. throw new \Exception($e->getMessage());
  208. }
  209. // create empty file in data dir, so we can later find
  210. // out that this is indeed an ownCloud data directory
  211. // (in case it didn't exist before)
  212. file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
  213. // pre-upgrade repairs
  214. $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher());
  215. $repair->run();
  216. $this->doCoreUpgrade();
  217. try {
  218. // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
  219. Setup::installBackgroundJobs();
  220. } catch (\Exception $e) {
  221. throw new \Exception($e->getMessage());
  222. }
  223. // update all shipped apps
  224. $this->checkAppsRequirements();
  225. $this->doAppUpgrade();
  226. // Update the appfetchers version so it downloads the correct list from the appstore
  227. \OC::$server->getAppFetcher()->setVersion($currentVersion);
  228. // upgrade appstore apps
  229. $this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps());
  230. $autoDisabledApps = \OC::$server->getAppManager()->getAutoDisabledApps();
  231. $this->upgradeAppStoreApps($autoDisabledApps, true);
  232. // install new shipped apps on upgrade
  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->get(Connection::class));
  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 (array_merge($priorityTypes, [$pseudoOtherType]) as $type) {
  289. $stack = $stacks[$type];
  290. foreach ($stack as $appId) {
  291. if (\OC_App::shouldUpgrade($appId)) {
  292. $this->emit('\OC\Updater', 'appUpgradeStarted', [$appId, \OC_App::getAppVersion($appId)]);
  293. \OC_App::updateApp($appId);
  294. $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]);
  295. }
  296. if ($type !== $pseudoOtherType) {
  297. // load authentication, filesystem and logging apps after
  298. // upgrading them. Other apps my need to rely on modifying
  299. // user and/or filesystem aspects.
  300. \OC_App::loadApp($appId);
  301. }
  302. }
  303. }
  304. }
  305. /**
  306. * check if the current enabled apps are compatible with the current
  307. * ownCloud version. disable them if not.
  308. * This is important if you upgrade ownCloud and have non ported 3rd
  309. * party apps installed.
  310. *
  311. * @return array
  312. * @throws \Exception
  313. */
  314. private function checkAppsRequirements() {
  315. $isCoreUpgrade = $this->isCodeUpgrade();
  316. $apps = OC_App::getEnabledApps();
  317. $version = implode('.', Util::getVersion());
  318. $disabledApps = [];
  319. $appManager = \OC::$server->getAppManager();
  320. foreach ($apps as $app) {
  321. // check if the app is compatible with this version of Nextcloud
  322. $info = OC_App::getAppInfo($app);
  323. if ($info === null || !OC_App::isAppCompatible($version, $info)) {
  324. if ($appManager->isShipped($app)) {
  325. throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update');
  326. }
  327. \OC::$server->getAppManager()->disableApp($app, true);
  328. $this->emit('\OC\Updater', 'incompatibleAppDisabled', [$app]);
  329. }
  330. // no need to disable any app in case this is a non-core upgrade
  331. if (!$isCoreUpgrade) {
  332. continue;
  333. }
  334. // shipped apps will remain enabled
  335. if ($appManager->isShipped($app)) {
  336. continue;
  337. }
  338. // authentication and session apps will remain enabled as well
  339. if (OC_App::isType($app, ['session', 'authentication'])) {
  340. continue;
  341. }
  342. }
  343. return $disabledApps;
  344. }
  345. /**
  346. * @return bool
  347. */
  348. private function isCodeUpgrade() {
  349. $installedVersion = $this->config->getSystemValue('version', '0.0.0');
  350. $currentVersion = implode('.', Util::getVersion());
  351. if (version_compare($currentVersion, $installedVersion, '>')) {
  352. return true;
  353. }
  354. return false;
  355. }
  356. /**
  357. * @param array $disabledApps
  358. * @param bool $reenable
  359. * @throws \Exception
  360. */
  361. private function upgradeAppStoreApps(array $disabledApps, $reenable = false) {
  362. foreach ($disabledApps as $app) {
  363. try {
  364. $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
  365. if ($this->installer->isUpdateAvailable($app)) {
  366. $this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]);
  367. $this->installer->updateAppstoreApp($app);
  368. }
  369. $this->emit('\OC\Updater', 'checkAppStoreApp', [$app]);
  370. if ($reenable) {
  371. $ocApp = new \OC_App();
  372. $ocApp->enable($app);
  373. }
  374. } catch (\Exception $ex) {
  375. $this->log->logException($ex, ['app' => 'core']);
  376. }
  377. }
  378. }
  379. /**
  380. * Forward messages emitted by the repair routine
  381. */
  382. private function emitRepairEvents() {
  383. $dispatcher = \OC::$server->getEventDispatcher();
  384. $dispatcher->addListener('\OC\Repair::warning', function ($event) {
  385. if ($event instanceof GenericEvent) {
  386. $this->emit('\OC\Updater', 'repairWarning', $event->getArguments());
  387. }
  388. });
  389. $dispatcher->addListener('\OC\Repair::error', function ($event) {
  390. if ($event instanceof GenericEvent) {
  391. $this->emit('\OC\Updater', 'repairError', $event->getArguments());
  392. }
  393. });
  394. $dispatcher->addListener('\OC\Repair::info', function ($event) {
  395. if ($event instanceof GenericEvent) {
  396. $this->emit('\OC\Updater', 'repairInfo', $event->getArguments());
  397. }
  398. });
  399. $dispatcher->addListener('\OC\Repair::step', function ($event) {
  400. if ($event instanceof GenericEvent) {
  401. $this->emit('\OC\Updater', 'repairStep', $event->getArguments());
  402. }
  403. });
  404. }
  405. private function logAllEvents() {
  406. $log = $this->log;
  407. $dispatcher = \OC::$server->getEventDispatcher();
  408. $dispatcher->addListener('\OC\DB\Migrator::executeSql', function ($event) use ($log) {
  409. if (!$event instanceof GenericEvent) {
  410. return;
  411. }
  412. $log->info('\OC\DB\Migrator::executeSql: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
  413. });
  414. $dispatcher->addListener('\OC\DB\Migrator::checkTable', function ($event) use ($log) {
  415. if (!$event instanceof GenericEvent) {
  416. return;
  417. }
  418. $log->info('\OC\DB\Migrator::checkTable: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
  419. });
  420. $repairListener = function ($event) use ($log) {
  421. if (!$event instanceof GenericEvent) {
  422. return;
  423. }
  424. switch ($event->getSubject()) {
  425. case '\OC\Repair::startProgress':
  426. $log->info('\OC\Repair::startProgress: Starting ... ' . $event->getArgument(1) . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
  427. break;
  428. case '\OC\Repair::advance':
  429. $desc = $event->getArgument(1);
  430. if (empty($desc)) {
  431. $desc = '';
  432. }
  433. $log->info('\OC\Repair::advance: ' . $desc . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
  434. break;
  435. case '\OC\Repair::finishProgress':
  436. $log->info('\OC\Repair::finishProgress', ['app' => 'updater']);
  437. break;
  438. case '\OC\Repair::step':
  439. $log->info('\OC\Repair::step: Repair step: ' . $event->getArgument(0), ['app' => 'updater']);
  440. break;
  441. case '\OC\Repair::info':
  442. $log->info('\OC\Repair::info: Repair info: ' . $event->getArgument(0), ['app' => 'updater']);
  443. break;
  444. case '\OC\Repair::warning':
  445. $log->warning('\OC\Repair::warning: Repair warning: ' . $event->getArgument(0), ['app' => 'updater']);
  446. break;
  447. case '\OC\Repair::error':
  448. $log->error('\OC\Repair::error: Repair error: ' . $event->getArgument(0), ['app' => 'updater']);
  449. break;
  450. }
  451. };
  452. $dispatcher->addListener('\OC\Repair::startProgress', $repairListener);
  453. $dispatcher->addListener('\OC\Repair::advance', $repairListener);
  454. $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener);
  455. $dispatcher->addListener('\OC\Repair::step', $repairListener);
  456. $dispatcher->addListener('\OC\Repair::info', $repairListener);
  457. $dispatcher->addListener('\OC\Repair::warning', $repairListener);
  458. $dispatcher->addListener('\OC\Repair::error', $repairListener);
  459. $this->listen('\OC\Updater', 'maintenanceEnabled', function () use ($log) {
  460. $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']);
  461. });
  462. $this->listen('\OC\Updater', 'maintenanceDisabled', function () use ($log) {
  463. $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']);
  464. });
  465. $this->listen('\OC\Updater', 'maintenanceActive', function () use ($log) {
  466. $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']);
  467. });
  468. $this->listen('\OC\Updater', 'updateEnd', function ($success) use ($log) {
  469. if ($success) {
  470. $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']);
  471. } else {
  472. $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']);
  473. }
  474. });
  475. $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($log) {
  476. $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']);
  477. });
  478. $this->listen('\OC\Updater', 'dbUpgrade', function () use ($log) {
  479. $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']);
  480. });
  481. $this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($log) {
  482. $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']);
  483. });
  484. $this->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($log) {
  485. $log->info('\OC\Updater::dbSimulateUpgrade: Checked database schema update', ['app' => 'updater']);
  486. });
  487. $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($log) {
  488. $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']);
  489. });
  490. $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($log) {
  491. $log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']);
  492. });
  493. $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($log) {
  494. $log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']);
  495. });
  496. $this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($log) {
  497. $log->info('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']);
  498. });
  499. $this->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($log) {
  500. $log->info('\OC\Updater::appUpgradeCheckBefore: Checking updates of apps', ['app' => 'updater']);
  501. });
  502. $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) {
  503. $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']);
  504. });
  505. $this->listen('\OC\Updater', 'appUpgradeCheck', function () use ($log) {
  506. $log->info('\OC\Updater::appUpgradeCheck: Checked database schema update for apps', ['app' => 'updater']);
  507. });
  508. $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) {
  509. $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']);
  510. });
  511. $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) {
  512. $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']);
  513. });
  514. $this->listen('\OC\Updater', 'failure', function ($message) use ($log) {
  515. $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']);
  516. });
  517. $this->listen('\OC\Updater', 'setDebugLogLevel', function () use ($log) {
  518. $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']);
  519. });
  520. $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($log) {
  521. $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']);
  522. });
  523. $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($log) {
  524. $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']);
  525. });
  526. $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($log) {
  527. $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']);
  528. });
  529. }
  530. }