You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Updater.php 22KB

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