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