Piwik\Plugins\CoreUpdater\Controller::runUpdaterAndExit PHP Method

runUpdaterAndExit() public method

public runUpdaterAndExit ( $doDryRun = null )
    public function runUpdaterAndExit($doDryRun = null)
    {
        $updater = new DbUpdater();
        $componentsWithUpdateFile = $updater->getComponentUpdates();
        if (empty($componentsWithUpdateFile)) {
            throw new NoUpdatesFoundException("Everything is already up to date.");
        }
        SettingsServer::setMaxExecutionTime(0);
        $welcomeTemplate = '@CoreUpdater/runUpdaterAndExit_welcome';
        $doneTemplate = '@CoreUpdater/runUpdaterAndExit_done';
        $viewWelcome = new View($welcomeTemplate);
        $this->addCustomLogoInfo($viewWelcome);
        $this->setBasicVariablesView($viewWelcome);
        $viewDone = new View($doneTemplate);
        $this->addCustomLogoInfo($viewDone);
        $this->setBasicVariablesView($viewDone);
        $doExecuteUpdates = Common::getRequestVar('updateCorePlugins', 0, 'integer') == 1;
        if (is_null($doDryRun)) {
            $doDryRun = !$doExecuteUpdates;
        }
        if ($doDryRun) {
            $viewWelcome->queries = $updater->getSqlQueriesToExecute();
            $viewWelcome->isMajor = $updater->hasMajorDbUpdate();
            $this->doWelcomeUpdates($viewWelcome, $componentsWithUpdateFile);
            return $viewWelcome->render();
        }
        // Web
        if ($doExecuteUpdates) {
            $this->warningMessages = array();
            $this->doExecuteUpdates($viewDone, $updater, $componentsWithUpdateFile);
            $this->redirectToDashboardWhenNoError($updater);
            return $viewDone->render();
        }
        exit;
    }

Usage Example

Example #1
0
 protected function makeUpdate(InputInterface $input, OutputInterface $output, $doDryRun)
 {
     $this->checkAllRequiredOptionsAreNotEmpty($input);
     $updateController = new Controller();
     echo $updateController->runUpdaterAndExit($doDryRun);
 }