Updater.php 22 KB

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