Updater.php 22 KB

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