private static function updateDatabase() { $updater = new Updater(); $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater); if (empty($componentsWithUpdateFile)) { throw new \Exception("Failed to update pre-2.0 database (nothing to update)."); } $result = CoreUpdater::updateComponents($updater, $componentsWithUpdateFile); if (!empty($result['coreError']) && !empty($result['warnings']) && !empty($result['errors'])) { throw new \Exception("Failed to update pre-2.0 database (errors or warnings found): " . print_r($result, true)); } }
private function doExecuteUpdates($view, $updater, $componentsWithUpdateFile) { $result = CoreUpdater::updateComponents($updater, $componentsWithUpdateFile); $this->coreError = $result['coreError']; $this->warningMessages = $result['warnings']; $this->errorMessages = $result['errors']; $this->deactivatedPlugins = $result['deactivatedPlugins']; $view->coreError = $this->coreError; $view->warningMessages = $this->warningMessages; $view->errorMessages = $this->errorMessages; $view->deactivatedPlugins = $this->deactivatedPlugins; }
/** * @return array|bool */ protected function updateComponents() { Access::getInstance(); Piwik::setUserHasSuperUserAccess(); $updater = new Updater(); $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater); if (empty($componentsWithUpdateFile)) { return false; } $result = CoreUpdater::updateComponents($updater, $componentsWithUpdateFile); return $result; }
public static function updateDatabase($force = false) { Cache::deleteTrackerCache(); Option::clearCache(); if ($force) { // remove version options to force update Option::deleteLike('version%'); Option::set('version_core', '0.0'); } $updater = new Updater(); $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater); if (empty($componentsWithUpdateFile)) { return false; } $result = CoreUpdater::updateComponents($updater, $componentsWithUpdateFile); if (!empty($result['coreError']) || !empty($result['warnings']) || !empty($result['errors'])) { throw new \Exception("Failed to update database (errors or warnings found): " . print_r($result, true)); } return $result; }
protected function runUpdaterAndExit() { $updater = new Updater(); $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater); if (empty($componentsWithUpdateFile)) { Piwik::redirectToModule('CoreHome'); } SettingsServer::setMaxExecutionTime(0); $cli = Common::isPhpCliMode() ? '_cli' : ''; $welcomeTemplate = '@CoreUpdater/runUpdaterAndExit_welcome' . $cli; $doneTemplate = '@CoreUpdater/runUpdaterAndExit_done' . $cli; $viewWelcome = new View($welcomeTemplate); $viewDone = new View($doneTemplate); if (Common::isPhpCliMode()) { $this->doWelcomeUpdates($viewWelcome, $componentsWithUpdateFile); $output = $viewWelcome->render(); if (!$this->coreError && Piwik::getModule() == 'CoreUpdater') { $this->doExecuteUpdates($viewDone, $updater, $componentsWithUpdateFile); $output .= $viewDone->render(); } return $output; } else { if (Common::getRequestVar('updateCorePlugins', 0, 'integer') == 1) { $this->warningMessages = array(); $this->doExecuteUpdates($viewDone, $updater, $componentsWithUpdateFile); $this->redirectToDashboardWhenNoError($updater); return $viewDone->render(); } else { $viewWelcome->queries = $updater->getSqlQueriesToExecute(); $viewWelcome->isMajor = $updater->hasMajorDbUpdate(); $this->doWelcomeUpdates($viewWelcome, $componentsWithUpdateFile); return $viewWelcome->render(); } } exit; }