recordComponentSuccessfullyUpdated() public static method

Record version of successfully completed component update
public static recordComponentSuccessfullyUpdated ( string $name, string $version )
$name string
$version string
Example #1
0
 public function testUpdaterChecksCoreAndPluginCheckThatCoreIsRanFirst()
 {
     $updater = new Updater();
     $updater->pathUpdateFilePlugins = PIWIK_INCLUDE_PATH . '/tests/resources/Updater/%s/';
     $updater->pathUpdateFileCore = PIWIK_INCLUDE_PATH . '/tests/resources/Updater/core/';
     $updater->recordComponentSuccessfullyUpdated('testpluginUpdates', '0.1beta');
     $updater->addComponentToCheck('testpluginUpdates', '0.1');
     $updater->recordComponentSuccessfullyUpdated('core', '0.1');
     $updater->addComponentToCheck('core', '0.3');
     $componentsWithUpdateFile = $updater->getComponentsWithUpdateFile();
     $this->assertEquals(2, count($componentsWithUpdateFile));
     reset($componentsWithUpdateFile);
     $this->assertEquals('core', key($componentsWithUpdateFile));
 }
Example #2
0
 /**
  * Installation Step 4: Table Creation
  */
 function tablesCreation()
 {
     $this->checkPiwikIsNotInstalled();
     $view = new View('@Installation/tablesCreation', $this->getInstallationSteps(), __FUNCTION__);
     if ($this->getParam('deleteTables')) {
         Manager::getInstance()->clearPluginsInstalledConfig();
         Db::dropAllTables();
         $view->existingTablesDeleted = true;
     }
     $tablesInstalled = DbHelper::getTablesInstalled();
     $view->tablesInstalled = '';
     if (count($tablesInstalled) > 0) {
         // we have existing tables
         $view->tablesInstalled = implode(', ', $tablesInstalled);
         $view->someTablesInstalled = true;
         Access::getInstance();
         Piwik::setUserHasSuperUserAccess();
         if ($this->hasEnoughTablesToReuseDb($tablesInstalled) && count(APISitesManager::getInstance()->getAllSitesId()) > 0 && count(APIUsersManager::getInstance()->getUsers()) > 0) {
             $view->showReuseExistingTables = true;
         }
     } else {
         DbHelper::createTables();
         DbHelper::createAnonymousUser();
         $this->updateComponents();
         Updater::recordComponentSuccessfullyUpdated('core', Version::VERSION);
         $view->tablesCreated = true;
         $view->showNextStep = true;
     }
     return $view->render();
 }
Example #3
0
 /**
  * Install a plugin, if necessary
  *
  * @param Plugin $plugin
  */
 private function installPluginIfNecessary(Plugin $plugin)
 {
     $pluginName = $plugin->getPluginName();
     $saveConfig = false;
     // is the plugin already installed or is it the first time we activate it?
     $pluginsInstalled = $this->getInstalledPluginsName();
     if (!$this->isPluginInstalled($pluginName)) {
         $this->executePluginInstall($plugin);
         $pluginsInstalled[] = $pluginName;
         $this->updatePluginsInstalledConfig($pluginsInstalled);
         Updater::recordComponentSuccessfullyUpdated($plugin->getPluginName(), $plugin->getVersion());
         $saveConfig = true;
     }
     if ($saveConfig) {
         PiwikConfig::getInstance()->forceSave();
     }
 }
Example #4
0
 /**
  * @param ActionDimension|ConversionDimension|VisitDimension $dimension
  * @param string $componentPrefix
  * @param array $columns
  * @param array $versions
  * @return array The modified versions array
  */
 private static function mixinVersions($dimension, $componentPrefix, $columns, $versions)
 {
     $columnName = $dimension->getColumnName();
     if (!$columnName || !$dimension->hasColumnType()) {
         return $versions;
     }
     $component = $componentPrefix . $columnName;
     $version = $dimension->getVersion();
     if (array_key_exists($columnName, $columns) && false === PiwikUpdater::getCurrentRecordedComponentVersion($component) && self::wasDimensionMovedFromCoreToPlugin($component, $version)) {
         PiwikUpdater::recordComponentSuccessfullyUpdated($component, $version);
         return $versions;
     }
     $versions[$component] = $version;
     return $versions;
 }
 /**
  * Installation Step 5: Table Creation
  */
 function tablesCreation()
 {
     $this->checkPreviousStepIsValid(__FUNCTION__);
     $view = new View('@Installation/tablesCreation', $this->getInstallationSteps(), __FUNCTION__);
     $this->skipThisStep(__FUNCTION__);
     $this->createDbFromSessionInformation();
     if (Common::getRequestVar('deleteTables', 0, 'int') == 1) {
         DbHelper::dropTables();
         $view->existingTablesDeleted = true;
         // when the user decides to drop the tables then we dont skip the next steps anymore
         // workaround ZF-1743
         $tmp = $this->session->skipThisStep;
         $tmp['firstWebsiteSetup'] = false;
         $tmp['trackingCode'] = false;
         $this->session->skipThisStep = $tmp;
     }
     $tablesInstalled = DbHelper::getTablesInstalled();
     $view->tablesInstalled = '';
     if (count($tablesInstalled) > 0) {
         // we have existing tables
         $view->tablesInstalled = implode(', ', $tablesInstalled);
         $view->someTablesInstalled = true;
         // remove monthly archive tables
         $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
         $baseTablesInstalled = count($tablesInstalled) - count($archiveTables);
         $minimumCountPiwikTables = 17;
         Access::getInstance();
         Piwik::setUserIsSuperUser();
         if ($baseTablesInstalled >= $minimumCountPiwikTables && count(APISitesManager::getInstance()->getAllSitesId()) > 0 && count(APIUsersManager::getInstance()->getUsers()) > 0) {
             $view->showReuseExistingTables = true;
             // when the user reuses the same tables we skip the website creation step
             // workaround ZF-1743
             $tmp = $this->session->skipThisStep;
             $tmp['firstWebsiteSetup'] = true;
             $tmp['trackingCode'] = true;
             $this->session->skipThisStep = $tmp;
         }
     } else {
         DbHelper::createTables();
         DbHelper::createAnonymousUser();
         Updater::recordComponentSuccessfullyUpdated('core', Version::VERSION);
         $view->tablesCreated = true;
         $view->showNextStep = true;
     }
     $this->session->currentStepDone = __FUNCTION__;
     return $view->render();
 }
Example #6
0
 /**
  * Install a specific plugin
  *
  * @param Plugin $plugin
  * @throws \Piwik\Plugin\Manager_PluginException if installation fails
  */
 private function installPlugin(Plugin $plugin)
 {
     try {
         $plugin->install();
     } catch (\Exception $e) {
         throw new \Piwik\Plugin\PluginException($plugin->getPluginName(), $e->getMessage());
     }
     Updater::recordComponentSuccessfullyUpdated($plugin->getPluginName(), $plugin->getVersion());
 }