diff options
author | Robin McCorkell <rmccorkell@owncloud.com> | 2015-08-27 00:36:46 +0100 |
---|---|---|
committer | Robin McCorkell <rmccorkell@owncloud.com> | 2015-08-27 00:36:46 +0100 |
commit | d4fca4985819f11c1fc258ea45486440e9feb7d3 (patch) | |
tree | 601959781cb0e4785f5af4680f552d4e2ba7967d /core | |
parent | 67a982bf8597cd03c9160344cc0d03130ffb6290 (diff) | |
parent | ce6045f84b833c35de5b507c4d15b2a753e476b9 (diff) | |
download | nextcloud-server-d4fca4985819f11c1fc258ea45486440e9feb7d3.tar.gz nextcloud-server-d4fca4985819f11c1fc258ea45486440e9feb7d3.zip |
Merge pull request #18574 from owncloud/update-eventsource-errors
Properly show update exception in web UI
Diffstat (limited to 'core')
-rw-r--r-- | core/ajax/update.php | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/core/ajax/update.php b/core/ajax/update.php index 14b4f913f76..a693deeb9cf 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -28,15 +28,19 @@ set_time_limit(0); require_once '../../lib/base.php'; -\OCP\JSON::callCheck(); +$l = \OC::$server->getL10N('core'); + +$eventSource = \OC::$server->createEventSource(); +// need to send an initial message to force-init the event source, +// which will then trigger its own CSRF check and produces its own CSRF error +// message +$eventSource->send('success', (string)$l->t('Preparing update')); if (OC::checkUpgrade(false)) { // if a user is currently logged in, their session must be ignored to // avoid side effects \OC_User::setIncognitoMode(true); - $l = new \OC_L10N('core'); - $eventSource = \OC::$server->createEventSource(); $logger = \OC::$server->getLogger(); $updater = new \OC\Updater( \OC::$server->getHTTPHelper(), @@ -85,7 +89,13 @@ if (OC::checkUpgrade(false)) { OC_Config::setValue('maintenance', false); }); - $updater->upgrade(); + try { + $updater->upgrade(); + } catch (\Exception $e) { + $eventSource->send('failure', get_class($e) . ': ' . $e->getMessage()); + $eventSource->close(); + exit(); + } if (!empty($incompatibleApps)) { $eventSource->send('notice', @@ -96,6 +106,10 @@ if (OC::checkUpgrade(false)) { (string)$l->t('Following apps have been disabled: %s', implode(', ', $disabledThirdPartyApps))); } - $eventSource->send('done', ''); - $eventSource->close(); +} else { + $eventSource->send('notice', (string)$l->t('Already up to date')); } + +$eventSource->send('done', ''); +$eventSource->close(); + |