Piwik\Updater::getSqlQueriesToExecute PHP Méthode

getSqlQueriesToExecute() public méthode

Returns the list of SQL queries that would be executed during the update
public getSqlQueriesToExecute ( ) : Sql[]
Résultat Piwik\Updater\Migration\Db\Sql[] of SQL queries
    public function getSqlQueriesToExecute()
    {
        $queries = array();
        $classNames = array();
        foreach ($this->componentsWithUpdateFile as $componentName => $componentUpdateInfo) {
            foreach ($componentUpdateInfo as $file => $fileVersion) {
                require_once $file;
                // prefixed by PIWIK_INCLUDE_PATH
                $className = $this->getUpdateClassName($componentName, $fileVersion);
                if (!class_exists($className, false)) {
                    throw new \Exception("The class {$className} was not found in {$file}");
                }
                if (in_array($className, $classNames)) {
                    continue;
                    // prevent from getting updates from Piwik\Columns\Updater multiple times
                }
                $classNames[] = $className;
                /** @var Updates $update */
                $update = StaticContainer::getContainer()->make($className);
                $migrationsForComponent = $update->getMigrations($this);
                foreach ($migrationsForComponent as $index => $migration) {
                    $migration = $this->keepBcForOldMigrationQueryFormat($index, $migration);
                    if ($migration instanceof Migration\Db) {
                        $queries[] = $migration;
                    }
                }
                $this->hasMajorDbUpdate = $this->hasMajorDbUpdate || call_user_func(array($className, 'isMajorUpdate'));
            }
        }
        return $queries;
    }

Usage Example

 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;
 }
All Usage Examples Of Piwik\Updater::getSqlQueriesToExecute