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:
authorThomas Steur <tsteur@users.noreply.github.com>2016-08-31 23:41:04 +0300
committerThomas Steur <thomas.steur@gmail.com>2016-08-31 16:11:00 +0300
commit5d52b777100f5acb82d16e947e0e9ab2c0804215 (patch)
treea67e294328c25ebe8beb20094ce732a616a9185d /plugins/CoreConsole
parent10a677a63034db3d7a54a90f6f2a9e48a82d1725 (diff)
update required piwik version automatically (#10457)
Diffstat (limited to 'plugins/CoreConsole')
-rw-r--r--plugins/CoreConsole/Commands/GeneratePluginBase.php41
1 files changed, 39 insertions, 2 deletions
diff --git a/plugins/CoreConsole/Commands/GeneratePluginBase.php b/plugins/CoreConsole/Commands/GeneratePluginBase.php
index 9012839943..f5ca71a405 100644
--- a/plugins/CoreConsole/Commands/GeneratePluginBase.php
+++ b/plugins/CoreConsole/Commands/GeneratePluginBase.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\CoreConsole\Commands;
+use Piwik\Common;
use Piwik\Development;
use Piwik\Filesystem;
use Piwik\Plugin\ConsoleCommand;
@@ -123,15 +124,51 @@ abstract class GeneratePluginBase extends ConsoleCommand
}
$piwikVersion = Version::VERSION;
- $newRequiredVersion = '>=' . $piwikVersion;
+ $nextMajorVersion = (int) $piwikVersion + 1;
+ $secondPartPiwikVersionRequire = ',<' . $nextMajorVersion . '.0.0-b1';
+ $newRequiredVersion = '>=' . $piwikVersion . $secondPartPiwikVersionRequire;
if (!empty($pluginJson['require']['piwik'])) {
- $requiredVersion = $pluginJson['require']['piwik'];
+ $requiredVersion = trim($pluginJson['require']['piwik']);
if ($requiredVersion === $newRequiredVersion) {
+ // there is nothing to updated
return;
}
+ // our generated versions look like ">=2.25.4,<3.0.0-b1".
+ // We only updated the Piwik version in the first part if the piwik version looks like that or if it has only
+ // one piwik version defined. In all other cases, eg user uses || etc we do not update it as user has customized
+ // the piwik version.
+
+ foreach (['<>','!=', '<=','==', '^'] as $comparison) {
+ if (strpos($requiredVersion, $comparison) === 0) {
+ // user is using custom piwik version require, we do not overwrite anything.
+ return;
+ }
+ }
+
+ if (strpos($requiredVersion, '||') !== false || strpos($requiredVersion, ' ') !== false) {
+ // user is using custom piwik version require, we do not overwrite anything.
+ return;
+ }
+
+ $requiredPiwikVersions = explode(',', (string) $requiredVersion);
+ $numRequiredPiwikVersions = count($requiredPiwikVersions);
+
+ if ($numRequiredPiwikVersions > 2) {
+ // user is using custom piwik version require, we do not overwrite anything.
+ return;
+ }
+
+ if ($numRequiredPiwikVersions === 2 &&
+ !Common::stringEndsWith($requiredVersion, $secondPartPiwikVersionRequire)) {
+ // user is using custom piwik version require, we do not overwrite anything
+ return;
+ }
+
+ // if only one piwik version is defined we update it to make sure it does now specify an upper version limit
+
$dependency = new Dependency();
$missingVersion = $dependency->getMissingVersions($piwikVersion, $requiredVersion);