Updates multiple components, while capturing & returning errors and warnings.
public updateComponents ( string[] $componentsWithUpdateFile ) : array | ||
$componentsWithUpdateFile | string[] | Component names mapped with arrays of update files. Same structure as the result of `getComponentsWithUpdateFile()`. |
리턴 | array | Information about the update process, including: * **warnings**: The list of warnings that occurred during the update process. * **errors**: The list of updater exceptions thrown during individual component updates. * **coreError**: True if an exception was thrown while updating core. * **deactivatedPlugins**: The list of plugins that were deactivated due to an error in the update process. |
private function doExecuteUpdates($view, DbUpdater $updater, $componentsWithUpdateFile) { $result = $updater->updateComponents($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; }
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 = $updater->getComponentUpdates(); if (empty($componentsWithUpdateFile)) { return false; } $result = $updater->updateComponents($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; }
private function doRealUpdate(Updater $updater, $componentsWithUpdateFile, OutputInterface $output) { $output->writeln(array(" " . Piwik::translate('CoreUpdater_TheUpgradeProcessMayTakeAWhilePleaseBePatient'), "")); $updaterResult = $updater->updateComponents($componentsWithUpdateFile); if (@$updaterResult['coreError']) { $this->handleCoreError($output, $updaterResult['errors'], $includeDiyHelp = true); return; } if (!empty($updaterResult['warnings'])) { $this->outputUpdaterWarnings($output, $updaterResult['warnings']); } if (!empty($updaterResult['errors'])) { $this->outputUpdaterErrors($output, $updaterResult['errors'], $updaterResult['deactivatedPlugins']); } if (!empty($updaterResult['warnings']) || !empty($updaterResult['errors'])) { $output->writeln(array(" " . Piwik::translate('CoreUpdater_HelpMessageIntroductionWhenWarning'), "", " * " . $this->getUpdateHelpMessage())); } }
/** * @return array|bool */ protected function updateComponents() { Access::getInstance(); return Access::doAsSuperUser(function () { $updater = new Updater(); $componentsWithUpdateFile = $updater->getComponentUpdates(); if (empty($componentsWithUpdateFile)) { return false; } $result = $updater->updateComponents($componentsWithUpdateFile); return $result; }); }
/** * @deprecated */ public static function updateComponents(PiwikCoreUpdater $updater, $componentsWithUpdateFile) { return $updater->updateComponents($componentsWithUpdateFile); }