markComponentSuccessfullyUpdated() public method

Marks a component as successfully updated to a specific version in the database. Sets an option that looks like "version_$componentName".
public markComponentSuccessfullyUpdated ( string $name, string $version, boolean $isNew = false )
$name string The component name. Eg, a plugin name, `'core'` or dimension column name.
$version string The component version (should use semantic versioning).
$isNew boolean indicates if the component is a new one (for plugins)
示例#1
0
 public function testUpdaterChecksCoreAndPluginCheckThatCoreIsRanFirst()
 {
     $updater = new Updater(PIWIK_INCLUDE_PATH . '/tests/resources/Updater/core/', PIWIK_INCLUDE_PATH . '/tests/resources/Updater/%s/');
     $updater->markComponentSuccessfullyUpdated('testpluginUpdates', '0.1beta');
     $updater->markComponentSuccessfullyUpdated('core', '0.1');
     $componentsWithUpdateFile = $updater->getComponentsWithUpdateFile(array('testpluginUpdates' => '0.1', 'core' => '0.3'));
     $this->assertEquals(2, count($componentsWithUpdateFile));
     reset($componentsWithUpdateFile);
     $this->assertEquals('core', key($componentsWithUpdateFile));
 }
示例#2
0
文件: Manager.php 项目: 962464/piwik
 /**
  * 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 = new Updater();
         $updater->markComponentSuccessfullyUpdated($plugin->getPluginName(), $plugin->getVersion());
         $saveConfig = true;
     }
     if ($saveConfig) {
         PiwikConfig::getInstance()->forceSave();
     }
 }
示例#3
0
 /**
  * @param ActionDimension|ConversionDimension|VisitDimension $dimension
  * @param string $componentPrefix
  * @param array $columns
  * @param array $versions
  * @return array The modified versions array
  */
 private function mixinVersions(PiwikUpdater $updater, $dimension, $componentPrefix, $columns, $versions)
 {
     $columnName = $dimension->getColumnName();
     // dimensions w/o columns do not need DB updates
     if (!$columnName || !$dimension->hasColumnType()) {
         return $versions;
     }
     $component = $componentPrefix . $columnName;
     $version = $dimension->getVersion();
     // if the column exists in the table, but has no associated version, and was one of the core columns
     // that was moved when the dimension refactor took place, then:
     // - set the installed version in the DB to the current code version
     // - and do not check for updates since we just set the version to the latest
     if (array_key_exists($columnName, $columns) && false === $updater->getCurrentComponentVersion($component) && self::wasDimensionMovedFromCoreToPlugin($component, $version)) {
         $updater->markComponentSuccessfullyUpdated($component, $version);
         return $versions;
     }
     $versions[$component] = $version;
     return $versions;
 }
示例#4
0
文件: Updater.php 项目: piwik/piwik
 /**
  * Record version of successfully completed component update
  *
  * @param string $name
  * @param string $version
  */
 public static function recordComponentSuccessfullyUpdated($name, $version)
 {
     self::$activeInstance->markComponentSuccessfullyUpdated($name, $version);
 }
示例#5
0
文件: Manager.php 项目: piwik/piwik
 /**
  * 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 = new Updater();
         $updater->markComponentSuccessfullyUpdated($plugin->getPluginName(), $plugin->getVersion(), $isNew = true);
         $saveConfig = true;
         /**
          * Event triggered after a new plugin has been installed.
          *
          * Note: Might be triggered more than once if the config file is not writable
          *
          * @param string $pluginName The plugin that has been installed.
          */
         Piwik::postEvent('PluginManager.pluginInstalled', array($pluginName));
     }
     if ($saveConfig) {
         PiwikConfig::getInstance()->forceSave();
         $this->clearCache($pluginName);
     }
 }