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.

update.php 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. set_time_limit(0);
  3. require_once '../../lib/base.php';
  4. \OCP\JSON::callCheck();
  5. if (OC::checkUpgrade(false)) {
  6. // if a user is currently logged in, their session must be ignored to
  7. // avoid side effects
  8. \OC_User::setIncognitoMode(true);
  9. $l = new \OC_L10N('core');
  10. $eventSource = \OC::$server->createEventSource();
  11. $updater = new \OC\Updater(
  12. \OC::$server->getHTTPHelper(),
  13. \OC::$server->getConfig(),
  14. \OC_Log::$object
  15. );
  16. $incompatibleApps = [];
  17. $disabledThirdPartyApps = [];
  18. $updater->listen('\OC\Updater', 'maintenanceStart', function () use ($eventSource, $l) {
  19. $eventSource->send('success', (string)$l->t('Turned on maintenance mode'));
  20. });
  21. $updater->listen('\OC\Updater', 'maintenanceEnd', function () use ($eventSource, $l) {
  22. $eventSource->send('success', (string)$l->t('Turned off maintenance mode'));
  23. });
  24. $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) {
  25. $eventSource->send('success', (string)$l->t('Updated database'));
  26. });
  27. $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) {
  28. $eventSource->send('success', (string)$l->t('Checked database schema update'));
  29. });
  30. $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) {
  31. $eventSource->send('success', (string)$l->t('Checked database schema update for apps'));
  32. });
  33. $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) {
  34. $eventSource->send('success', (string)$l->t('Updated "%s" to %s', array($app, $version)));
  35. });
  36. $updater->listen('\OC\Updater', 'repairWarning', function ($description) use ($eventSource, $l) {
  37. $eventSource->send('notice', (string)$l->t('Repair warning: ') . $description);
  38. });
  39. $updater->listen('\OC\Updater', 'repairError', function ($description) use ($eventSource, $l) {
  40. $eventSource->send('notice', (string)$l->t('Repair error: ') . $description);
  41. });
  42. $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) {
  43. $incompatibleApps[]= $app;
  44. });
  45. $updater->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use (&$disabledThirdPartyApps) {
  46. $disabledThirdPartyApps[]= $app;
  47. });
  48. $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource) {
  49. $eventSource->send('failure', $message);
  50. $eventSource->close();
  51. OC_Config::setValue('maintenance', false);
  52. });
  53. $updater->upgrade();
  54. if (!empty($incompatibleApps)) {
  55. $eventSource->send('notice',
  56. (string)$l->t('Following incompatible apps have been disabled: %s', implode(', ', $incompatibleApps)));
  57. }
  58. if (!empty($disabledThirdPartyApps)) {
  59. $eventSource->send('notice',
  60. (string)$l->t('Following 3rd party apps have been disabled: %s', implode(', ', $disabledThirdPartyApps)));
  61. }
  62. $eventSource->send('done', '');
  63. $eventSource->close();
  64. }