nextcloud/core/ajax/update.php

50 lines
2.0 KiB
PHP
Raw Normal View History

<?php
set_time_limit(0);
require_once '../../lib/base.php';
if (OC::checkUpgrade(false)) {
// if a user is currently logged in, their session must be ignored to
// avoid side effects
\OC_User::setIncognitoMode(true);
2013-08-27 02:26:44 +04:00
$l = new \OC_L10N('core');
2014-09-04 03:10:02 +04:00
$eventSource = \OC::$server->createEventSource();
2013-07-06 19:00:00 +04:00
$updater = new \OC\Updater(\OC_Log::$object);
2013-08-27 02:26:44 +04:00
$updater->listen('\OC\Updater', 'maintenanceStart', function () use ($eventSource, $l) {
$eventSource->send('success', (string)$l->t('Turned on maintenance mode'));
2013-07-06 19:00:00 +04:00
});
2013-08-27 02:26:44 +04:00
$updater->listen('\OC\Updater', 'maintenanceEnd', function () use ($eventSource, $l) {
$eventSource->send('success', (string)$l->t('Turned off maintenance mode'));
2013-07-06 19:00:00 +04:00
});
2013-08-27 02:26:44 +04:00
$updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) {
$eventSource->send('success', (string)$l->t('Updated database'));
2013-07-06 19:00:00 +04:00
});
$updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) {
$eventSource->send('success', (string)$l->t('Checked database schema update'));
});
$updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) {
$eventSource->send('success', (string)$l->t('Checked database schema update for apps'));
});
$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) {
$eventSource->send('success', (string)$l->t('Updated "%s" to %s', array($app, $version)));
});
$updater->listen('\OC\Updater', 'disabledApps', function ($appList) use ($eventSource, $l) {
$list = array();
foreach ($appList as $appId) {
$info = OC_App::getAppInfo($appId);
$list[] = $info['name'] . ' (' . $info['id'] . ')';
}
$eventSource->send('success', (string)$l->t('Disabled incompatible apps: %s', implode(', ', $list)));
});
2013-07-06 19:00:00 +04:00
$updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource) {
$eventSource->send('failure', $message);
$eventSource->close();
OC_Config::setValue('maintenance', false);
2013-07-06 19:00:00 +04:00
});
2013-01-04 19:21:33 +04:00
2013-07-06 19:00:00 +04:00
$updater->upgrade();
2013-01-04 19:21:33 +04:00
2013-07-06 19:00:00 +04:00
$eventSource->send('done', '');
$eventSource->close();
}