/** * runs the update actions in maintenance mode, does not upgrade the source files */ public function upgrade() { \OC_DB::enableCaching(false); \OC_Config::setValue('maintenance', true); $installedVersion = \OC_Config::getValue('version', '0.0.0'); $currentVersion = implode('.', \OC_Util::getVersion()); if ($this->log) { $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core')); } $this->emit('\\OC\\Updater', 'maintenanceStart'); try { \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml'); $this->emit('\\OC\\Updater', 'dbUpgrade'); // do a file cache upgrade for users with files // this can take loooooooooooooooooooooooong $this->upgradeFileCache(); } catch (\Exception $exception) { $this->emit('\\OC\\Updater', 'failure', array($exception->getMessage())); } \OC_Config::setValue('version', implode('.', \OC_Util::getVersion())); \OC_App::checkAppsRequirements(); // load all apps to also upgrade enabled apps \OC_App::loadApps(); $repair = new Repair(); $repair->run(); \OC_Config::setValue('maintenance', false); $this->emit('\\OC\\Updater', 'maintenanceEnd'); }
/** * runs the update actions in maintenance mode, does not upgrade the source files */ public function upgrade() { \OC_DB::enableCaching(false); \OC_Config::setValue('maintenance', true); $installedVersion = \OC_Config::getValue('version', '0.0.0'); $currentVersion = implode('.', \OC_Util::getVersion()); if ($this->log) { $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core')); } $this->emit('\\OC\\Updater', 'maintenanceStart'); // create empty file in data dir, so we can later find // out that this is indeed an ownCloud data directory // (in case it didn't exist before) file_put_contents(\OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); /* * START CONFIG CHANGES FOR OLDER VERSIONS */ if (!\OC::$CLI && version_compare($installedVersion, '6.00.4', '<')) { // Add the trusted_domains config if it is not existant // This is added to prevent host header poisoning \OC_Config::setValue('trusted_domains', \OC_Config::getValue('trusted_domains', array(\OC_Request::serverHost()))); } /* * STOP CONFIG CHANGES FOR OLDER VERSIONS */ try { \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml'); $this->emit('\\OC\\Updater', 'dbUpgrade'); // do a file cache upgrade for users with files // this can take loooooooooooooooooooooooong $this->upgradeFileCache(); } catch (\Exception $exception) { $this->emit('\\OC\\Updater', 'failure', array($exception->getMessage())); } \OC_Config::setValue('version', implode('.', \OC_Util::getVersion())); \OC_App::checkAppsRequirements(); // load all apps to also upgrade enabled apps \OC_App::loadApps(); $repair = new Repair(); $repair->run(); //Invalidate update feed \OC_Appconfig::setValue('core', 'lastupdatedat', 0); \OC_Config::setValue('maintenance', false); $this->emit('\\OC\\Updater', 'maintenanceEnd'); }
/** * runs the update actions in maintenance mode, does not upgrade the source files * except the main .htaccess file * * @return bool true if the operation succeeded, false otherwise */ public function upgrade() { \OC_DB::enableCaching(false); \OC_Config::setValue('maintenance', true); $installedVersion = \OC_Config::getValue('version', '0.0.0'); $currentVersion = implode('.', \OC_Util::getVersion()); if ($this->log) { $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core')); } $this->emit('\\OC\\Updater', 'maintenanceStart'); try { $this->doUpgrade($currentVersion, $installedVersion); } catch (\Exception $exception) { $this->emit('\\OC\\Updater', 'failure', array($exception->getMessage())); } \OC_Config::setValue('maintenance', false); $this->emit('\\OC\\Updater', 'maintenanceEnd'); }
<?php set_time_limit(0); $RUNTIME_NOAPPS = true; require_once '../../lib/base.php'; if (OC::checkUpgrade(false)) { \OC_DB::enableCaching(false); // initialize the event source before we enter maintenance mode because CSRF protection can terminate the script $updateEventSource = new OC_EventSource(); OC_Config::setValue('maintenance', true); $installedVersion = OC_Config::getValue('version', '0.0.0'); $currentVersion = implode('.', OC_Util::getVersion()); OC_Log::write('core', 'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::WARN); $watcher = new UpdateWatcher($updateEventSource); OC_Hook::connect('update', 'success', $watcher, 'success'); OC_Hook::connect('update', 'failure', $watcher, 'failure'); $watcher->success('Turned on maintenance mode'); try { $result = OC_DB::updateDbFromStructure(OC::$SERVERROOT . '/db_structure.xml'); $watcher->success('Updated database'); // do a file cache upgrade for users with files // this can take loooooooooooooooooooooooong __doFileCacheUpgrade($watcher); } catch (Exception $exception) { $watcher->failure($exception->getMessage()); } OC_Config::setValue('version', implode('.', OC_Util::getVersion())); OC_App::checkAppsRequirements(); // load all apps to also upgrade enabled apps OC_App::loadApps(); OC_Config::setValue('maintenance', false);
/** * runs the update actions in maintenance mode, does not upgrade the source files * except the main .htaccess file * * @return bool true if the operation succeeded, false otherwise */ public function upgrade() { $logLevel = \OC_Config::getValue('loglevel', \OCP\Util::WARN); $this->emit('\\OC\\Updater', 'setDebugLogLevel', array($logLevel, $this->logLevelNames[$logLevel])); \OC_Config::setValue('loglevel', \OCP\Util::DEBUG); \OC_DB::enableCaching(false); \OC_Config::setValue('maintenance', true); $installedVersion = \OC_Config::getValue('version', '0.0.0'); $currentVersion = implode('.', \OC_Util::getVersion()); if ($this->log) { $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core')); } $this->emit('\\OC\\Updater', 'maintenanceStart'); $success = true; try { $this->doUpgrade($currentVersion, $installedVersion); } catch (\Exception $exception) { \OCP\Util::logException('update', $exception); $this->emit('\\OC\\Updater', 'failure', array(get_class($exception) . ': ' . $exception->getMessage())); $success = false; } \OC_Config::setValue('maintenance', false); $this->emit('\\OC\\Updater', 'maintenanceEnd'); $this->emit('\\OC\\Updater', 'updateEnd', array($success)); $this->emit('\\OC\\Updater', 'resetLogLevel', array($logLevel, $this->logLevelNames[$logLevel])); \OC_Config::setValue('loglevel', $logLevel); return $success; }