Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2020-04-16 09:07:48 +0300
committerGitHub <noreply@github.com>2020-04-16 09:07:48 +0300
commite943702e1e54bfc71d423bfd2ec2a48c0a4610f7 (patch)
tree3e22b427c2173bf396e3ca4b3d36fd3f33c4385b /core/Plugin/Dependency.php
parent97cf78a8a1365a9485597f2f24d1edb0becf099a (diff)
Assume plugins that do not define a upper bound for Matomo version re… (#15796)
* Assume plugins that do not define a upper bound for Matomo version requirement as incompatible with Matomo 4 * improve version dependency detection * improve/fix tests
Diffstat (limited to 'core/Plugin/Dependency.php')
-rw-r--r--core/Plugin/Dependency.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/core/Plugin/Dependency.php b/core/Plugin/Dependency.php
index 157a53cebd..5c2598d1bd 100644
--- a/core/Plugin/Dependency.php
+++ b/core/Plugin/Dependency.php
@@ -43,6 +43,11 @@ class Dependency
foreach ($requires as $name => $requiredVersion) {
$currentVersion = $this->getCurrentVersion($name);
+
+ if (in_array(strtolower($name), ['piwik', 'matomo'])) {
+ $requiredVersion = $this->markPluginsWithoutUpperBoundMatomoRequirementAsIncompatible($requiredVersion);
+ }
+
$missingVersions = $this->getMissingVersions($currentVersion, $requiredVersion);
if (!empty($missingVersions)) {
@@ -97,6 +102,31 @@ class Dependency
return $missingVersions;
}
+ /**
+ * Upon Matomo 4 we require a lower and upper version bound for Matomo to be set in plugin.json
+ * If that is not the case we assume the plugin not to be compatible with Matomo 4
+ *
+ * @param string $requiredVersion
+ * @return string
+ */
+ private function markPluginsWithoutUpperBoundMatomoRequirementAsIncompatible($requiredVersion)
+ {
+ if (strpos($requiredVersion, ',') !== false) {
+ return $requiredVersion;
+ }
+
+ $minVersion = str_replace(array('>', '=', '<', '!', '~', '^'), '', $requiredVersion);
+ if (preg_match("/^\<=?\d/", $requiredVersion)) {
+ $upperLimit = '>=' . $minVersion[0] . '.0.0-b1,' . $requiredVersion;
+ } else if (!empty($minVersion) && is_numeric($minVersion[0])) {
+ $upperLimit = $requiredVersion . ',<' . ($minVersion[0] + 1) . '.0.0-b1';
+ } else {
+ $upperLimit = '>=4.0.0-b1,<5.0.0-b1';
+ }
+
+ return $upperLimit;
+ }
+
private function makeVersionBackwardsCompatibleIfNoComparisonDefined($version)
{
if (!empty($version) && preg_match('/^(\d+)\.(\d+)/', $version)) {