1
0

Updater.php 22 KB

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