Updater.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  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 <pvince81@owncloud.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, array('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', array($exception->getMessage() . ': ' .$exception->getHint()));
  118. $success = false;
  119. } catch (\Exception $exception) {
  120. $this->log->logException($exception, ['app' => 'core']);
  121. $this->emit('\OC\Updater', 'failure', array(get_class($exception) . ': ' .$exception->getMessage()));
  122. $success = false;
  123. }
  124. $this->emit('\OC\Updater', 'updateEnd', array($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 === '' && isset($allowedPreviousVersions['owncloud'][$oldVersion])) {
  171. $currentVendor = 'owncloud';
  172. }
  173. if ($currentVendor === 'nextcloud') {
  174. return isset($allowedPreviousVersions[$currentVendor][$majorMinor])
  175. && (version_compare($oldVersion, $newVersion, '<=') ||
  176. $this->config->getSystemValue('debug', false));
  177. }
  178. // Check if the instance can be migrated
  179. return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) ||
  180. isset($allowedPreviousVersions[$currentVendor][$oldVersion]);
  181. }
  182. /**
  183. * runs the update actions in maintenance mode, does not upgrade the source files
  184. * except the main .htaccess file
  185. *
  186. * @param string $currentVersion current version to upgrade to
  187. * @param string $installedVersion previous version from which to upgrade from
  188. *
  189. * @throws \Exception
  190. */
  191. private function doUpgrade($currentVersion, $installedVersion) {
  192. // Stop update if the update is over several major versions
  193. $allowedPreviousVersions = $this->getAllowedPreviousVersions();
  194. if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
  195. throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
  196. }
  197. // Update .htaccess files
  198. try {
  199. Setup::updateHtaccess();
  200. Setup::protectDataDirectory();
  201. } catch (\Exception $e) {
  202. throw new \Exception($e->getMessage());
  203. }
  204. // create empty file in data dir, so we can later find
  205. // out that this is indeed an ownCloud data directory
  206. // (in case it didn't exist before)
  207. file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
  208. // pre-upgrade repairs
  209. $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher());
  210. $repair->run();
  211. $this->doCoreUpgrade();
  212. try {
  213. // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
  214. Setup::installBackgroundJobs();
  215. } catch (\Exception $e) {
  216. throw new \Exception($e->getMessage());
  217. }
  218. // update all shipped apps
  219. $this->checkAppsRequirements();
  220. $this->doAppUpgrade();
  221. // Update the appfetchers version so it downloads the correct list from the appstore
  222. \OC::$server->getAppFetcher()->setVersion($currentVersion);
  223. // upgrade appstore apps
  224. $this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps());
  225. $autoDisabledApps = \OC::$server->getAppManager()->getAutoDisabledApps();
  226. $this->upgradeAppStoreApps($autoDisabledApps, true);
  227. // install new shipped apps on upgrade
  228. OC_App::loadApps(['authentication']);
  229. $errors = Installer::installShippedApps(true);
  230. foreach ($errors as $appId => $exception) {
  231. /** @var \Exception $exception */
  232. $this->log->logException($exception, ['app' => $appId]);
  233. $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
  234. }
  235. // post-upgrade repairs
  236. $repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher());
  237. $repair->run();
  238. //Invalidate update feed
  239. $this->config->setAppValue('core', 'lastupdatedat', 0);
  240. // Check for code integrity if not disabled
  241. if(\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) {
  242. $this->emit('\OC\Updater', 'startCheckCodeIntegrity');
  243. $this->checker->runInstanceVerification();
  244. $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity');
  245. }
  246. // only set the final version if everything went well
  247. $this->config->setSystemValue('version', implode('.', Util::getVersion()));
  248. $this->config->setAppValue('core', 'vendor', $this->getVendor());
  249. }
  250. protected function doCoreUpgrade() {
  251. $this->emit('\OC\Updater', 'dbUpgradeBefore');
  252. // execute core migrations
  253. $ms = new MigrationService('core', \OC::$server->getDatabaseConnection());
  254. $ms->migrate();
  255. $this->emit('\OC\Updater', 'dbUpgrade');
  256. }
  257. /**
  258. * @param string $version the oc version to check app compatibility with
  259. */
  260. protected function checkAppUpgrade($version) {
  261. $apps = \OC_App::getEnabledApps();
  262. $this->emit('\OC\Updater', 'appUpgradeCheckBefore');
  263. $appManager = \OC::$server->getAppManager();
  264. foreach ($apps as $appId) {
  265. $info = \OC_App::getAppInfo($appId);
  266. $compatible = \OC_App::isAppCompatible($version, $info);
  267. $isShipped = $appManager->isShipped($appId);
  268. if ($compatible && $isShipped && \OC_App::shouldUpgrade($appId)) {
  269. /**
  270. * FIXME: The preupdate check is performed before the database migration, otherwise database changes
  271. * are not possible anymore within it. - Consider this when touching the code.
  272. * @link https://github.com/owncloud/core/issues/10980
  273. * @see \OC_App::updateApp
  274. */
  275. if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/preupdate.php')) {
  276. $this->includePreUpdate($appId);
  277. }
  278. if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) {
  279. $this->emit('\OC\Updater', 'appSimulateUpdate', array($appId));
  280. \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml');
  281. }
  282. }
  283. }
  284. $this->emit('\OC\Updater', 'appUpgradeCheck');
  285. }
  286. /**
  287. * Includes the pre-update file. Done here to prevent namespace mixups.
  288. * @param string $appId
  289. */
  290. private function includePreUpdate($appId) {
  291. include \OC_App::getAppPath($appId) . '/appinfo/preupdate.php';
  292. }
  293. /**
  294. * upgrades all apps within a major ownCloud upgrade. Also loads "priority"
  295. * (types authentication, filesystem, logging, in that order) afterwards.
  296. *
  297. * @throws NeedsUpdateException
  298. */
  299. protected function doAppUpgrade() {
  300. $apps = \OC_App::getEnabledApps();
  301. $priorityTypes = array('authentication', 'filesystem', 'logging');
  302. $pseudoOtherType = 'other';
  303. $stacks = array($pseudoOtherType => array());
  304. foreach ($apps as $appId) {
  305. $priorityType = false;
  306. foreach ($priorityTypes as $type) {
  307. if(!isset($stacks[$type])) {
  308. $stacks[$type] = array();
  309. }
  310. if (\OC_App::isType($appId, [$type])) {
  311. $stacks[$type][] = $appId;
  312. $priorityType = true;
  313. break;
  314. }
  315. }
  316. if (!$priorityType) {
  317. $stacks[$pseudoOtherType][] = $appId;
  318. }
  319. }
  320. foreach ($stacks as $type => $stack) {
  321. foreach ($stack as $appId) {
  322. if (\OC_App::shouldUpgrade($appId)) {
  323. $this->emit('\OC\Updater', 'appUpgradeStarted', [$appId, \OC_App::getAppVersion($appId)]);
  324. \OC_App::updateApp($appId);
  325. $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]);
  326. }
  327. if($type !== $pseudoOtherType) {
  328. // load authentication, filesystem and logging apps after
  329. // upgrading them. Other apps my need to rely on modifying
  330. // user and/or filesystem aspects.
  331. \OC_App::loadApp($appId);
  332. }
  333. }
  334. }
  335. }
  336. /**
  337. * check if the current enabled apps are compatible with the current
  338. * ownCloud version. disable them if not.
  339. * This is important if you upgrade ownCloud and have non ported 3rd
  340. * party apps installed.
  341. *
  342. * @return array
  343. * @throws \Exception
  344. */
  345. private function checkAppsRequirements() {
  346. $isCoreUpgrade = $this->isCodeUpgrade();
  347. $apps = OC_App::getEnabledApps();
  348. $version = implode('.', Util::getVersion());
  349. $disabledApps = [];
  350. $appManager = \OC::$server->getAppManager();
  351. foreach ($apps as $app) {
  352. // check if the app is compatible with this version of ownCloud
  353. $info = OC_App::getAppInfo($app);
  354. if($info === null || !OC_App::isAppCompatible($version, $info)) {
  355. if ($appManager->isShipped($app)) {
  356. throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update');
  357. }
  358. \OC::$server->getAppManager()->disableApp($app, true);
  359. $this->emit('\OC\Updater', 'incompatibleAppDisabled', array($app));
  360. }
  361. // no need to disable any app in case this is a non-core upgrade
  362. if (!$isCoreUpgrade) {
  363. continue;
  364. }
  365. // shipped apps will remain enabled
  366. if ($appManager->isShipped($app)) {
  367. continue;
  368. }
  369. // authentication and session apps will remain enabled as well
  370. if (OC_App::isType($app, ['session', 'authentication'])) {
  371. continue;
  372. }
  373. }
  374. return $disabledApps;
  375. }
  376. /**
  377. * @return bool
  378. */
  379. private function isCodeUpgrade() {
  380. $installedVersion = $this->config->getSystemValue('version', '0.0.0');
  381. $currentVersion = implode('.', Util::getVersion());
  382. if (version_compare($currentVersion, $installedVersion, '>')) {
  383. return true;
  384. }
  385. return false;
  386. }
  387. /**
  388. * @param array $disabledApps
  389. * @param bool $reenable
  390. * @throws \Exception
  391. */
  392. private function upgradeAppStoreApps(array $disabledApps, $reenable = false) {
  393. foreach($disabledApps as $app) {
  394. try {
  395. $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
  396. if ($this->installer->isUpdateAvailable($app)) {
  397. $this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]);
  398. $this->installer->updateAppstoreApp($app);
  399. }
  400. $this->emit('\OC\Updater', 'checkAppStoreApp', [$app]);
  401. if ($reenable) {
  402. $ocApp = new \OC_App();
  403. $ocApp->enable($app);
  404. }
  405. } catch (\Exception $ex) {
  406. $this->log->logException($ex, ['app' => 'core']);
  407. }
  408. }
  409. }
  410. /**
  411. * Forward messages emitted by the repair routine
  412. */
  413. private function emitRepairEvents() {
  414. $dispatcher = \OC::$server->getEventDispatcher();
  415. $dispatcher->addListener('\OC\Repair::warning', function ($event) {
  416. if ($event instanceof GenericEvent) {
  417. $this->emit('\OC\Updater', 'repairWarning', $event->getArguments());
  418. }
  419. });
  420. $dispatcher->addListener('\OC\Repair::error', function ($event) {
  421. if ($event instanceof GenericEvent) {
  422. $this->emit('\OC\Updater', 'repairError', $event->getArguments());
  423. }
  424. });
  425. $dispatcher->addListener('\OC\Repair::info', function ($event) {
  426. if ($event instanceof GenericEvent) {
  427. $this->emit('\OC\Updater', 'repairInfo', $event->getArguments());
  428. }
  429. });
  430. $dispatcher->addListener('\OC\Repair::step', function ($event) {
  431. if ($event instanceof GenericEvent) {
  432. $this->emit('\OC\Updater', 'repairStep', $event->getArguments());
  433. }
  434. });
  435. }
  436. private function logAllEvents() {
  437. $log = $this->log;
  438. $dispatcher = \OC::$server->getEventDispatcher();
  439. $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($log) {
  440. if (!$event instanceof GenericEvent) {
  441. return;
  442. }
  443. $log->info('\OC\DB\Migrator::executeSql: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
  444. });
  445. $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($log) {
  446. if (!$event instanceof GenericEvent) {
  447. return;
  448. }
  449. $log->info('\OC\DB\Migrator::checkTable: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
  450. });
  451. $repairListener = function($event) use ($log) {
  452. if (!$event instanceof GenericEvent) {
  453. return;
  454. }
  455. switch ($event->getSubject()) {
  456. case '\OC\Repair::startProgress':
  457. $log->info('\OC\Repair::startProgress: Starting ... ' . $event->getArgument(1) . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
  458. break;
  459. case '\OC\Repair::advance':
  460. $desc = $event->getArgument(1);
  461. if (empty($desc)) {
  462. $desc = '';
  463. }
  464. $log->info('\OC\Repair::advance: ' . $desc . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
  465. break;
  466. case '\OC\Repair::finishProgress':
  467. $log->info('\OC\Repair::finishProgress', ['app' => 'updater']);
  468. break;
  469. case '\OC\Repair::step':
  470. $log->info('\OC\Repair::step: Repair step: ' . $event->getArgument(0), ['app' => 'updater']);
  471. break;
  472. case '\OC\Repair::info':
  473. $log->info('\OC\Repair::info: Repair info: ' . $event->getArgument(0), ['app' => 'updater']);
  474. break;
  475. case '\OC\Repair::warning':
  476. $log->warning('\OC\Repair::warning: Repair warning: ' . $event->getArgument(0), ['app' => 'updater']);
  477. break;
  478. case '\OC\Repair::error':
  479. $log->error('\OC\Repair::error: Repair error: ' . $event->getArgument(0), ['app' => 'updater']);
  480. break;
  481. }
  482. };
  483. $dispatcher->addListener('\OC\Repair::startProgress', $repairListener);
  484. $dispatcher->addListener('\OC\Repair::advance', $repairListener);
  485. $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener);
  486. $dispatcher->addListener('\OC\Repair::step', $repairListener);
  487. $dispatcher->addListener('\OC\Repair::info', $repairListener);
  488. $dispatcher->addListener('\OC\Repair::warning', $repairListener);
  489. $dispatcher->addListener('\OC\Repair::error', $repairListener);
  490. $this->listen('\OC\Updater', 'maintenanceEnabled', function () use($log) {
  491. $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']);
  492. });
  493. $this->listen('\OC\Updater', 'maintenanceDisabled', function () use($log) {
  494. $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']);
  495. });
  496. $this->listen('\OC\Updater', 'maintenanceActive', function () use($log) {
  497. $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']);
  498. });
  499. $this->listen('\OC\Updater', 'updateEnd', function ($success) use($log) {
  500. if ($success) {
  501. $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']);
  502. } else {
  503. $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']);
  504. }
  505. });
  506. $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use($log) {
  507. $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']);
  508. });
  509. $this->listen('\OC\Updater', 'dbUpgrade', function () use($log) {
  510. $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']);
  511. });
  512. $this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($log) {
  513. $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']);
  514. });
  515. $this->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($log) {
  516. $log->info('\OC\Updater::dbSimulateUpgrade: Checked database schema update', ['app' => 'updater']);
  517. });
  518. $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($log) {
  519. $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']);
  520. });
  521. $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($log) {
  522. $log->info('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']);
  523. });
  524. $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($log) {
  525. $log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']);
  526. });
  527. $this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($log) {
  528. $log->info('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']);
  529. });
  530. $this->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($log) {
  531. $log->info('\OC\Updater::appUpgradeCheckBefore: Checking updates of apps', ['app' => 'updater']);
  532. });
  533. $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) {
  534. $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']);
  535. });
  536. $this->listen('\OC\Updater', 'appUpgradeCheck', function () use ($log) {
  537. $log->info('\OC\Updater::appUpgradeCheck: Checked database schema update for apps', ['app' => 'updater']);
  538. });
  539. $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) {
  540. $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']);
  541. });
  542. $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) {
  543. $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']);
  544. });
  545. $this->listen('\OC\Updater', 'failure', function ($message) use($log) {
  546. $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']);
  547. });
  548. $this->listen('\OC\Updater', 'setDebugLogLevel', function () use($log) {
  549. $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']);
  550. });
  551. $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($log) {
  552. $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']);
  553. });
  554. $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($log) {
  555. $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']);
  556. });
  557. $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($log) {
  558. $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']);
  559. });
  560. }
  561. }