getCurrentComponentVersion() public method

Returns the currently installed version of a Piwik component.
public getCurrentComponentVersion ( string $name ) : string
$name string The component name. Eg, a plugin name, `'core'` or dimension column name.
return string A semantic version.
 /**
  * This method ensures that Piwik Platform cannot be running when using a NEWER database.
  */
 private function throwIfPiwikVersionIsOlderThanDBSchema()
 {
     // When developing this situation happens often when switching branches
     if (Development::isEnabled()) {
         return;
     }
     $updater = new Updater();
     $dbSchemaVersion = $updater->getCurrentComponentVersion('core');
     $current = Version::VERSION;
     if (-1 === version_compare($current, $dbSchemaVersion)) {
         $messages = array(Piwik::translate('General_ExceptionDatabaseVersionNewerThanCodebase', array($current, $dbSchemaVersion)), Piwik::translate('General_ExceptionDatabaseVersionNewerThanCodebaseWait'), Piwik::translate('General_ExceptionContactSupportGeneric', array('', '')));
         throw new DatabaseSchemaIsNewerThanCodebaseException(implode(" ", $messages));
     }
 }
Example #2
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;
 }
Example #3
0
 private function getCurrentVersionForCore(Updater $updater)
 {
     $currentVersion = $updater->getCurrentComponentVersion('core');
     if ($currentVersion === false) {
         $currentVersion = "<= 0.2.9";
     }
     return $currentVersion;
 }
Example #4
0
 /**
  * Retrieve the current version of a recorded component
  * @param string $name
  * @return false|string
  * @throws \Exception
  */
 public static function getCurrentRecordedComponentVersion($name)
 {
     return self::$activeInstance->getCurrentComponentVersion($name);
 }