Updater.php 22 KB

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