Пример #1
0
$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);
    $logger = \OC::$server->getLogger();
    $config = \OC::$server->getConfig();
    $updater = new \OC\Updater(\OC::$server->getHTTPHelper(), $config, \OC::$server->getIntegrityCodeChecker(), $logger);
    if ($config->getSystemValue('update.skip-migration-test', false)) {
        $eventSource->send('success', (string) $l->t('Migration tests are skipped - "update.skip-migration-test" is activated in config.php'));
        $updater->setSimulateStepEnabled(false);
    }
    $incompatibleApps = [];
    $disabledThirdPartyApps = [];
    $updater->listen('\\OC\\Updater', 'maintenanceEnabled', function () use($eventSource, $l) {
        $eventSource->send('success', (string) $l->t('Turned on maintenance mode'));
    });
    $updater->listen('\\OC\\Updater', 'maintenanceDisabled', function () use($eventSource, $l) {
        $eventSource->send('success', (string) $l->t('Turned off maintenance mode'));
    });
    $updater->listen('\\OC\\Updater', 'maintenanceActive', function () use($eventSource, $l) {
        $eventSource->send('success', (string) $l->t('Maintenance mode is kept active'));
    });
    $updater->listen('\\OC\\Updater', 'dbUpgradeBefore', function () use($eventSource, $l) {
        $eventSource->send('success', (string) $l->t('Updating database schema'));
    });