diff --git a/core/modules/update/src/Form/UpdateManagerUpdate.php b/core/modules/update/src/Form/UpdateManagerUpdate.php
index a5b6b675c1..b4e50be9db 100644
--- a/core/modules/update/src/Form/UpdateManagerUpdate.php
+++ b/core/modules/update/src/Form/UpdateManagerUpdate.php
@@ -10,7 +10,7 @@
use Drupal\Core\Url;
use Drupal\update\UpdateFetcherInterface;
use Drupal\update\UpdateManagerInterface;
-use Drupal\update\ModuleVersionParser;
+use Drupal\update\ModuleVersion;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -136,7 +136,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$recommended_release = $project['releases'][$project['recommended']];
$recommended_version = '{{ release_version }} ({{ release_notes }})';
- $recommended_version_parser = new ModuleVersionParser($recommended_release['version']);
+ $recommended_version_parser = new ModuleVersion($recommended_release['version']);
if ($recommended_version_parser->getMajorVersion() != $project['existing_major']) {
$recommended_version .= '
{{ major_update_warning_text }}
';
}
diff --git a/core/modules/update/src/ModuleVersionParser.php b/core/modules/update/src/ModuleVersion.php
similarity index 64%
rename from core/modules/update/src/ModuleVersionParser.php
rename to core/modules/update/src/ModuleVersion.php
index 6855adc2fa..0d78a59e96 100644
--- a/core/modules/update/src/ModuleVersionParser.php
+++ b/core/modules/update/src/ModuleVersion.php
@@ -3,9 +3,9 @@
namespace Drupal\update;
/**
- * Provides a module version parser.
+ * Provides a module version value object.
*/
-class ModuleVersionParser {
+class ModuleVersion {
/**
* The version_string.
@@ -15,17 +15,25 @@ class ModuleVersionParser {
protected $version;
/**
- * Constructs a ModuleVersionParser object.
+ * The version, without the core compatibility prefix, split apart by commas.
+ *
+ * @var array
+ */
+ protected $versionParts;
+
+ /**
+ * Constructs a ModuleVersion object.
*
* @param string $version
* The version string.
*/
public function __construct($version) {
$this->version = $version;
+ $this->versionParts = explode('.', $this->getVersionStringWithoutCoreCompatibility());
}
/**
- * Constructs a module version parser from a support branch.
+ * Constructs a module version object from a support branch.
*
* This can be used to determine the major and minor versions. The patch
* version will always be NULL.
@@ -33,8 +41,8 @@ public function __construct($version) {
* @param string $branch
* The support branch.
*
- * @return \Drupal\update\ModuleVersionParser
- * The module version parser.
+ * @return \Drupal\update\ModuleVersion
+ * The module version instance.
*/
public static function createFromSupportBranch($branch) {
return new static ($branch . 'x');
@@ -47,7 +55,7 @@ public static function createFromSupportBranch($branch) {
* The major version.
*/
public function getMajorVersion() {
- return explode('.', $this->getVersionStringWithoutCoreCompatibility())[0];
+ return $this->versionParts[0];
}
/**
@@ -57,8 +65,7 @@ public function getMajorVersion() {
* The minor version if available otherwise NULL.
*/
public function getMinorVersion() {
- $version_parts = explode('.', $this->getVersionStringWithoutCoreCompatibility());
- return count($version_parts) === 2 ? NULL : $version_parts[1];
+ return count($this->versionParts) === 2 ? NULL : $this->versionParts[1];
}
/**
@@ -68,22 +75,21 @@ public function getMinorVersion() {
* The patch version.
*/
public function getPatchVersion() {
- $version_parts = explode('.', $this->getVersionStringWithoutCoreCompatibility());
- $last_version_part = count($version_parts) === 2 ? $version_parts[1] : $version_parts[2];
+ $last_version_part = count($this->versionParts) === 2 ? $this->versionParts[1] : $this->versionParts[2];
$patch = explode('-', $last_version_part)[0];
- // If patch equals 'x' this parser was created from a branch and the patch
+ // If patch equals 'x' this instance was created from a branch and the patch
// version cannot be determined.
return $patch === 'x' ? NULL : $patch;
}
/**
- * Gets the version string.
+ * Gets the version string with the core compatibility prefix removed.
*
* @return string
* The version string.
*/
private function getVersionStringWithoutCoreCompatibility() {
- $version = strpos($this->version, '8.x-') === 0 ? str_replace('8.x-', '', $this->version) : $this->version;
+ $version = strpos($this->version, \Drupal::CORE_COMPATIBILITY) === 0 ? str_replace('8.x-', '', $this->version) : $this->version;
return $version;
}
@@ -94,8 +100,7 @@ private function getVersionStringWithoutCoreCompatibility() {
* The version extra string if available otherwise NULL.
*/
public function getVersionExtra() {
- $version_parts = explode('.', $this->getVersionStringWithoutCoreCompatibility());
- $last_version_parts = explode('-', count($version_parts) === 2 ? $version_parts[1] : $version_parts[2]);
+ $last_version_parts = explode('-', count($this->versionParts) === 2 ? $this->versionParts[1] : $this->versionParts[2]);
return count($last_version_parts) === 1 ? NULL : $last_version_parts[1];
}
diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.1_1-alpha1.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.1_1-alpha1.xml
index 61776abbdf..9552804b1d 100644
--- a/core/modules/update/tests/modules/update_test/aaa_update_test.1_1-alpha1.xml
+++ b/core/modules/update/tests/modules/update_test/aaa_update_test.1_1-alpha1.xml
@@ -4,9 +4,7 @@
aaa_update_test
Drupal
8.x
- 1
- 1
- 1
+ 8.x-1.
published
http://example.com/project/aaa_update_test
@@ -17,9 +15,6 @@
aaa_update_test 8.x-1.1-alpha1
8.x-1.1-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 1
- alpha1
published
http://example.com/aaa_update_test-8-x-1-1-alpha1-release
http://example.com/aaa_update_test-8.x-1.1-alpha1.tar.gz
@@ -35,8 +30,6 @@
aaa_update_test 8.x-1.0
8.x-1.0
DRUPAL-8--1-0
- 1
- 0
published
http://example.com/aaa_update_test-8-x-1-0-release
http://example.com/aaa_update_test-8.x-1.0.tar.gz
diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.1_1-beta1.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.1_1-beta1.xml
index 4cb6e450a5..0e23635b5a 100644
--- a/core/modules/update/tests/modules/update_test/aaa_update_test.1_1-beta1.xml
+++ b/core/modules/update/tests/modules/update_test/aaa_update_test.1_1-beta1.xml
@@ -4,9 +4,7 @@
aaa_update_test
Drupal
8.x
-1
-1
-1
+8.x-1.
published
http://example.com/project/aaa_update_test
@@ -17,9 +15,6 @@
aaa_update_test 8.x-1.1-beta1
8.x-1.1-beta1
DRUPAL-8--1-1-beta1
- 1
- 1
- beta1
published
http://example.com/aaa_update_test-8-x-1-1-beta1-release
http://example.com/aaa_update_test-8.x-1.1-beta1.tar.gz
@@ -35,9 +30,6 @@
aaa_update_test 8.x-1.1-alpha1
8.x-1.1-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 1
- alpha1
published
http://example.com/aaa_update_test-8-x-1-1-alpha1-release
http://example.com/aaa_update_test-8.x-1.1-alpha1.tar.gz
@@ -53,8 +45,6 @@
aaa_update_test 8.x-1.0
8.x-1.0
DRUPAL-8--1-0
- 1
- 0
published
http://example.com/aaa_update_test-8-x-1-0-release
http://example.com/aaa_update_test-8.x-1.0.tar.gz
diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.1_1.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.1_1.xml
index 14e9e7c169..7c5392b4f3 100644
--- a/core/modules/update/tests/modules/update_test/aaa_update_test.1_1.xml
+++ b/core/modules/update/tests/modules/update_test/aaa_update_test.1_1.xml
@@ -4,9 +4,7 @@
aaa_update_test
Drupal
8.x
-1
-1
-1
+8.x-1.
published
http://example.com/project/aaa_update_test
@@ -17,8 +15,6 @@
aaa_update_test 8.x-1.1
8.x-1.1
DRUPAL-8--1-1
- 1
- 1
published
http://example.com/aaa_update_test-8-x-1-1-release
http://example.com/aaa_update_test-8.x-1.1.tar.gz
@@ -34,9 +30,6 @@
aaa_update_test 8.x-1.1-beta1
8.x-1.1-beta1
DRUPAL-8--1-1-beta1
- 1
- 1
- beta1
published
http://example.com/aaa_update_test-8-x-1-1-beta1-release
http://example.com/aaa_update_test-8.x-1.1-beta1.tar.gz
@@ -52,9 +45,6 @@
aaa_update_test 8.x-1.1-alpha1
8.x-1.1-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 1
- alpha1
published
http://example.com/aaa_update_test-8-x-1-1-alpha1-release
http://example.com/aaa_update_test-8.x-1.1-alpha1.tar.gz
@@ -70,8 +60,6 @@
aaa_update_test 8.x-1.0
8.x-1.0
DRUPAL-8--1-0
- 1
- 0
published
http://example.com/aaa_update_test-8-x-1-0-release
http://example.com/aaa_update_test-8.x-1.0.tar.gz
diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.1_2-alpha1.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.1_2-alpha1.xml
index f9541c8f5f..aa6f3cfde4 100644
--- a/core/modules/update/tests/modules/update_test/aaa_update_test.1_2-alpha1.xml
+++ b/core/modules/update/tests/modules/update_test/aaa_update_test.1_2-alpha1.xml
@@ -4,9 +4,7 @@
aaa_update_test
Drupal
8.x
-1
-1
-1
+8.x-1.
published
http://example.com/project/aaa_update_test
@@ -17,9 +15,6 @@
aaa_update_test 8.x-1.2-alpha1
8.x-1.2-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 2
- alpha1
published
http://example.com/aaa_update_test-8-x-1-2-alpha1-release
http://example.com/aaa_update_test-8.x-1.2-alpha1.tar.gz
@@ -35,8 +30,6 @@
aaa_update_test 8.x-1.1
8.x-1.1
DRUPAL-8--1-1
- 1
- 1
published
http://example.com/aaa_update_test-8-x-1-1-release
http://example.com/aaa_update_test-8.x-1.1.tar.gz
@@ -52,9 +45,6 @@
aaa_update_test 8.x-1.1-beta1
8.x-1.1-beta1
DRUPAL-8--1-1-beta1
- 1
- 1
- beta1
published
http://example.com/aaa_update_test-8-x-1-1-beta1-release
http://example.com/aaa_update_test-8.x-1.1-beta1.tar.gz
@@ -70,9 +60,6 @@
aaa_update_test 8.x-1.1-alpha1
8.x-1.1-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 1
- alpha1
published
http://example.com/aaa_update_test-8-x-1-1-alpha1-release
http://example.com/aaa_update_test-8.x-1.1-alpha1.tar.gz
@@ -88,8 +75,6 @@
aaa_update_test 8.x-1.0
8.x-1.0
DRUPAL-8--1-0
- 1
- 0
published
http://example.com/aaa_update_test-8-x-1-0-release
http://example.com/aaa_update_test-8.x-1.0.tar.gz
diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.1_2-beta1.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.1_2-beta1.xml
index e166b3af98..dea994db0e 100644
--- a/core/modules/update/tests/modules/update_test/aaa_update_test.1_2-beta1.xml
+++ b/core/modules/update/tests/modules/update_test/aaa_update_test.1_2-beta1.xml
@@ -4,9 +4,7 @@
aaa_update_test
Drupal
8.x
-1
-1
-1
+8.x-1.
published
http://example.com/project/aaa_update_test
@@ -17,9 +15,6 @@
aaa_update_test 8.x-1.2-beta1
8.x-1.2-beta1
DRUPAL-8--1-1-beta1
- 1
- 2
- beta1
published
http://example.com/aaa_update_test-8-x-1-2-beta1-release
http://example.com/aaa_update_test-8.x-1.2-beta1.tar.gz
@@ -35,9 +30,6 @@
aaa_update_test 8.x-1.2-alpha1
8.x-1.2-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 2
- alpha1
published
http://example.com/aaa_update_test-8-x-1-2-alpha1-release
http://example.com/aaa_update_test-8.x-1.2-alpha1.tar.gz
@@ -53,8 +45,6 @@
aaa_update_test 8.x-1.1
8.x-1.1
DRUPAL-8--1-1
- 1
- 1
published
http://example.com/aaa_update_test-8-x-1-1-release
http://example.com/aaa_update_test-8.x-1.1.tar.gz
@@ -70,9 +60,6 @@
aaa_update_test 8.x-1.1-beta1
8.x-1.1-beta1
DRUPAL-8--1-1-beta1
- 1
- 1
- beta1
published
http://example.com/aaa_update_test-8-x-1-1-beta1-release
http://example.com/aaa_update_test-8.x-1.1-beta1.tar.gz
@@ -88,9 +75,6 @@
aaa_update_test 8.x-1.1-alpha1
8.x-1.1-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 1
- alpha1
published
http://example.com/aaa_update_test-8-x-1-1-alpha1-release
http://example.com/aaa_update_test-8.x-1.1-alpha1.tar.gz
@@ -106,8 +90,6 @@
aaa_update_test 8.x-1.0
8.x-1.0
DRUPAL-8--1-0
- 1
- 0
published
http://example.com/aaa_update_test-8-x-1-0-release
http://example.com/aaa_update_test-8.x-1.0.tar.gz
diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.1_2.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.1_2.xml
index d3d30934f7..7b52b6ca6b 100644
--- a/core/modules/update/tests/modules/update_test/aaa_update_test.1_2.xml
+++ b/core/modules/update/tests/modules/update_test/aaa_update_test.1_2.xml
@@ -4,9 +4,7 @@
aaa_update_test
Drupal
8.x
-1
-1
-1
+8.x-1.
published
http://example.com/project/aaa_update_test
@@ -17,8 +15,6 @@
aaa_update_test 8.x-1.2
8.x-1.2
DRUPAL-8--1-1
- 1
- 2
published
http://example.com/aaa_update_test-8-x-1-2-release
http://example.com/aaa_update_test-8.x-1.2.tar.gz
@@ -34,9 +30,6 @@
aaa_update_test 8.x-1.2-beta1
8.x-1.2-beta1
DRUPAL-8--1-1-beta1
- 1
- 2
- beta1
published
http://example.com/aaa_update_test-8-x-1-2-beta1-release
http://example.com/aaa_update_test-8.x-1.2-beta1.tar.gz
@@ -52,9 +45,6 @@
aaa_update_test 8.x-1.2-alpha1
8.x-1.2-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 2
- alpha1
published
http://example.com/aaa_update_test-8-x-1-2-alpha1-release
http://example.com/aaa_update_test-8.x-1.2-alpha1.tar.gz
@@ -70,8 +60,6 @@
aaa_update_test 8.x-1.1
8.x-1.1
DRUPAL-8--1-1
- 1
- 1
published
http://example.com/aaa_update_test-8-x-1-1-release
http://example.com/aaa_update_test-8.x-1.1.tar.gz
@@ -87,9 +75,6 @@
aaa_update_test 8.x-1.1-beta1
8.x-1.1-beta1
DRUPAL-8--1-1-beta1
- 1
- 1
- beta1
published
http://example.com/aaa_update_test-8-x-1-1-beta1-release
http://example.com/aaa_update_test-8.x-1.1-beta1.tar.gz
@@ -105,9 +90,6 @@
aaa_update_test 8.x-1.1-alpha1
8.x-1.1-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 1
- alpha1
published
http://example.com/aaa_update_test-8-x-1-1-alpha1-release
http://example.com/aaa_update_test-8.x-1.1-alpha1.tar.gz
@@ -123,8 +105,6 @@
aaa_update_test 8.x-1.0
8.x-1.0
DRUPAL-8--1-0
- 1
- 0
published
http://example.com/aaa_update_test-8-x-1-0-release
http://example.com/aaa_update_test-8.x-1.0.tar.gz
diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.2_0-alpha1.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.2_0-alpha1.xml
index 799abdbd3d..a9d0911ebc 100644
--- a/core/modules/update/tests/modules/update_test/aaa_update_test.2_0-alpha1.xml
+++ b/core/modules/update/tests/modules/update_test/aaa_update_test.2_0-alpha1.xml
@@ -4,9 +4,7 @@
aaa_update_test
Drupal
8.x
-1
-1,2
-1
+8.x-1.,8.x-2.
published
http://example.com/project/aaa_update_test
@@ -17,9 +15,6 @@
aaa_update_test 8.x-2.0-alpha1
8.x-2.0-alpha1
DRUPAL-8--2-0
- 2
- 0
- alpha1
published
http://example.com/aaa_update_test-8-x-2-0-alpha1-release
http://example.com/aaa_update_test-8.x-2.0-alpha1.tar.gz
@@ -35,8 +30,6 @@
aaa_update_test 8.x-1.2
8.x-1.2
DRUPAL-8--1-1
- 1
- 2
published
http://example.com/aaa_update_test-8-x-1-2-release
http://example.com/aaa_update_test-8.x-1.2.tar.gz
@@ -52,9 +45,6 @@
aaa_update_test 8.x-1.2-beta1
8.x-1.2-beta1
DRUPAL-8--1-1-beta1
- 1
- 2
- beta1
published
http://example.com/aaa_update_test-8-x-1-2-beta1-release
http://example.com/aaa_update_test-8.x-1.2-beta1.tar.gz
@@ -70,9 +60,6 @@
aaa_update_test 8.x-1.2-alpha1
8.x-1.2-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 2
- alpha1
published
http://example.com/aaa_update_test-8-x-1-2-alpha1-release
http://example.com/aaa_update_test-8.x-1.2-alpha1.tar.gz
@@ -88,8 +75,6 @@
aaa_update_test 8.x-1.1
8.x-1.1
DRUPAL-8--1-1
- 1
- 1
published
http://example.com/aaa_update_test-8-x-1-1-release
http://example.com/aaa_update_test-8.x-1.1.tar.gz
@@ -105,9 +90,6 @@
aaa_update_test 8.x-1.1-beta1
8.x-1.1-beta1
DRUPAL-8--1-1-beta1
- 1
- 1
- beta1
published
http://example.com/aaa_update_test-8-x-1-1-beta1-release
http://example.com/aaa_update_test-8.x-1.1-beta1.tar.gz
@@ -123,9 +105,6 @@
aaa_update_test 8.x-1.1-alpha1
8.x-1.1-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 1
- alpha1
published
http://example.com/aaa_update_test-8-x-1-1-alpha1-release
http://example.com/aaa_update_test-8.x-1.1-alpha1.tar.gz
@@ -141,8 +120,6 @@
aaa_update_test 8.x-1.0
8.x-1.0
DRUPAL-8--1-0
- 1
- 0
published
http://example.com/aaa_update_test-8-x-1-0-release
http://example.com/aaa_update_test-8.x-1.0.tar.gz
diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.2_0-beta1.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.2_0-beta1.xml
index e82a27f051..a2f7d7b33e 100644
--- a/core/modules/update/tests/modules/update_test/aaa_update_test.2_0-beta1.xml
+++ b/core/modules/update/tests/modules/update_test/aaa_update_test.2_0-beta1.xml
@@ -4,9 +4,7 @@
aaa_update_test
Drupal
8.x
-1
-1,2
-1
+8.x-1.,8.x-2.
published
http://example.com/project/aaa_update_test
@@ -17,13 +15,10 @@
aaa_update_test 8.x-2.0-beta1
8.x-2.0-beta1
DRUPAL-8--2-0
- 2
- 0
- beta1
published
http://example.com/aaa_update_test-8-x-2-0-beta1-release
http://example.com/aaa_update_test-8.x-2.0-beta1.tar.gz
- 1250422521
+ 1250442521
b966255555d9c9b86d480ca08cfaa98e
1073782824
@@ -35,9 +30,6 @@
aaa_update_test 8.x-2.0-alpha1
8.x-2.0-alpha1
DRUPAL-8--2-0
- 2
- 0
- alpha1
published
http://example.com/aaa_update_test-8-x-2-0-alpha1-release
http://example.com/aaa_update_test-8.x-2.0-alpha1.tar.gz
@@ -53,8 +45,6 @@
aaa_update_test 8.x-1.2
8.x-1.2
DRUPAL-8--1-1
- 1
- 2
published
http://example.com/aaa_update_test-8-x-1-2-release
http://example.com/aaa_update_test-8.x-1.2.tar.gz
@@ -70,9 +60,6 @@
aaa_update_test 8.x-1.2-beta1
8.x-1.2-beta1
DRUPAL-8--1-1-beta1
- 1
- 2
- beta1
published
http://example.com/aaa_update_test-8-x-1-2-beta1-release
http://example.com/aaa_update_test-8.x-1.2-beta1.tar.gz
@@ -88,9 +75,6 @@
aaa_update_test 8.x-1.2-alpha1
8.x-1.2-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 2
- alpha1
published
http://example.com/aaa_update_test-8-x-1-2-alpha1-release
http://example.com/aaa_update_test-8.x-1.2-alpha1.tar.gz
@@ -106,8 +90,6 @@
aaa_update_test 8.x-1.1
8.x-1.1
DRUPAL-8--1-1
- 1
- 1
published
http://example.com/aaa_update_test-8-x-1-1-release
http://example.com/aaa_update_test-8.x-1.1.tar.gz
@@ -123,9 +105,6 @@
aaa_update_test 8.x-1.1-beta1
8.x-1.1-beta1
DRUPAL-8--1-1-beta1
- 1
- 1
- beta1
published
http://example.com/aaa_update_test-8-x-1-1-beta1-release
http://example.com/aaa_update_test-8.x-1.1-beta1.tar.gz
@@ -141,9 +120,6 @@
aaa_update_test 8.x-1.1-alpha1
8.x-1.1-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 1
- alpha1
published
http://example.com/aaa_update_test-8-x-1-1-alpha1-release
http://example.com/aaa_update_test-8.x-1.1-alpha1.tar.gz
@@ -159,8 +135,6 @@
aaa_update_test 8.x-1.0
8.x-1.0
DRUPAL-8--1-0
- 1
- 0
published
http://example.com/aaa_update_test-8-x-1-0-release
http://example.com/aaa_update_test-8.x-1.0.tar.gz
diff --git a/core/modules/update/tests/modules/update_test/aaa_update_test.2_0.xml b/core/modules/update/tests/modules/update_test/aaa_update_test.2_0.xml
index 240f0db4fb..6b92613c1a 100644
--- a/core/modules/update/tests/modules/update_test/aaa_update_test.2_0.xml
+++ b/core/modules/update/tests/modules/update_test/aaa_update_test.2_0.xml
@@ -4,9 +4,7 @@
aaa_update_test
Drupal
8.x
-1
-1,2
-1
+8.x-1.,8.x-2.
published
http://example.com/project/aaa_update_test
@@ -17,8 +15,6 @@
aaa_update_test 8.x-2.0
8.x-2.0
DRUPAL-8--2-0
- 2
- 0
published
http://example.com/aaa_update_test-8-x-2-0-release
http://example.com/aaa_update_test-8.x-2.0.tar.gz
@@ -34,9 +30,6 @@
aaa_update_test 8.x-2.0-beta1
8.x-2.0-beta1
DRUPAL-8--2-0
- 2
- 0
- beta1
published
http://example.com/aaa_update_test-8-x-2-0-beta1-release
http://example.com/aaa_update_test-8.x-2.0-beta1.tar.gz
@@ -52,9 +45,6 @@
aaa_update_test 8.x-2.0-alpha1
8.x-2.0-alpha1
DRUPAL-8--2-0
- 2
- 0
- alpha1
published
http://example.com/aaa_update_test-8-x-2-0-alpha1-release
http://example.com/aaa_update_test-8.x-2.0-alpha1.tar.gz
@@ -70,8 +60,6 @@
aaa_update_test 8.x-1.2
8.x-1.2
DRUPAL-8--1-1
- 1
- 2
published
http://example.com/aaa_update_test-8-x-1-2-release
http://example.com/aaa_update_test-8.x-1.2.tar.gz
@@ -87,9 +75,6 @@
aaa_update_test 8.x-1.2-beta1
8.x-1.2-beta1
DRUPAL-8--1-1-beta1
- 1
- 2
- beta1
published
http://example.com/aaa_update_test-8-x-1-2-beta1-release
http://example.com/aaa_update_test-8.x-1.2-beta1.tar.gz
@@ -105,9 +90,6 @@
aaa_update_test 8.x-1.2-alpha1
8.x-1.2-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 2
- alpha1
published
http://example.com/aaa_update_test-8-x-1-2-alpha1-release
http://example.com/aaa_update_test-8.x-1.2-alpha1.tar.gz
@@ -123,8 +105,6 @@
aaa_update_test 8.x-1.1
8.x-1.1
DRUPAL-8--1-1
- 1
- 1
published
http://example.com/aaa_update_test-8-x-1-1-release
http://example.com/aaa_update_test-8.x-1.1.tar.gz
@@ -140,9 +120,6 @@
aaa_update_test 8.x-1.1-beta1
8.x-1.1-beta1
DRUPAL-8--1-1-beta1
- 1
- 1
- beta1
published
http://example.com/aaa_update_test-8-x-1-1-beta1-release
http://example.com/aaa_update_test-8.x-1.1-beta1.tar.gz
@@ -158,9 +135,6 @@
aaa_update_test 8.x-1.1-alpha1
8.x-1.1-alpha1
DRUPAL-8--1-1-alpha1
- 1
- 1
- alpha1
published
http://example.com/aaa_update_test-8-x-1-1-alpha1-release
http://example.com/aaa_update_test-8.x-1.1-alpha1.tar.gz
@@ -176,8 +150,6 @@
aaa_update_test 8.x-1.0
8.x-1.0
DRUPAL-8--1-0
- 1
- 0
published
http://example.com/aaa_update_test-8-x-1-0-release
http://example.com/aaa_update_test-8.x-1.0.tar.gz
diff --git a/core/modules/update/tests/src/Unit/ModuleVersionParserTest.php b/core/modules/update/tests/src/Unit/ModuleVersionTest.php
similarity index 67%
rename from core/modules/update/tests/src/Unit/ModuleVersionParserTest.php
rename to core/modules/update/tests/src/Unit/ModuleVersionTest.php
index f38950443d..75d427ffb5 100644
--- a/core/modules/update/tests/src/Unit/ModuleVersionParserTest.php
+++ b/core/modules/update/tests/src/Unit/ModuleVersionTest.php
@@ -3,14 +3,14 @@
namespace Drupal\Tests\update\Unit;
use Drupal\Tests\UnitTestCase;
-use Drupal\update\ModuleVersionParser;
+use Drupal\update\ModuleVersion;
/**
- * @coversDefaultClass \Drupal\update\ModuleVersionParser
+ * @coversDefaultClass \Drupal\update\ModuleVersion
*
* @group update
*/
-class ModuleVersionParserTest extends UnitTestCase {
+class ModuleVersionTest extends UnitTestCase {
/**
* @covers ::getMajorVersion
@@ -18,8 +18,8 @@ class ModuleVersionParserTest extends UnitTestCase {
* @dataProvider providerVersionInfos
*/
public function testGetMajorVersion($version, $excepted_version_info) {
- $parser = new ModuleVersionParser($version);
- $this->assertSame($excepted_version_info['major'], $parser->getMajorVersion());
+ $version = new ModuleVersion($version);
+ $this->assertSame($excepted_version_info['major'], $version->getMajorVersion());
}
/**
@@ -28,8 +28,8 @@ public function testGetMajorVersion($version, $excepted_version_info) {
* @dataProvider providerVersionInfos
*/
public function testGetMinorVersion($version, $excepted_version_info) {
- $parser = new ModuleVersionParser($version);
- $this->assertSame($excepted_version_info['minor'], $parser->getMinorVersion());
+ $version = new ModuleVersion($version);
+ $this->assertSame($excepted_version_info['minor'], $version->getMinorVersion());
}
/**
@@ -38,8 +38,8 @@ public function testGetMinorVersion($version, $excepted_version_info) {
* @dataProvider providerVersionInfos
*/
public function testGetPatchVersion($version, $excepted_version_info) {
- $parser = new ModuleVersionParser($version);
- $this->assertSame($excepted_version_info['patch'], $parser->getPatchVersion());
+ $version = new ModuleVersion($version);
+ $this->assertSame($excepted_version_info['patch'], $version->getPatchVersion());
}
/**
@@ -48,8 +48,8 @@ public function testGetPatchVersion($version, $excepted_version_info) {
* @dataProvider providerVersionInfos
*/
public function testGetVersionExtra($version, $excepted_version_info) {
- $parser = new ModuleVersionParser($version);
- $this->assertSame($excepted_version_info['extra'], $parser->getVersionExtra());
+ $version = new ModuleVersion($version);
+ $this->assertSame($excepted_version_info['extra'], $version->getVersionExtra());
}
/**
@@ -58,8 +58,8 @@ public function testGetVersionExtra($version, $excepted_version_info) {
* @dataProvider providerVersionInfos
*/
public function testGetSupportBranch($version, $excepted_version_info) {
- $parser = new ModuleVersionParser($version);
- $this->assertSame($excepted_version_info['branch'], $parser->getSupportBranch());
+ $version = new ModuleVersion($version);
+ $this->assertSame($excepted_version_info['branch'], $version->getSupportBranch());
}
/**
@@ -68,13 +68,13 @@ public function testGetSupportBranch($version, $excepted_version_info) {
* @dataProvider providerVersionInfos
*/
public function testCreateFromSupportBranch($version, $excepted_version_info) {
- $parser = ModuleVersionParser::createFromSupportBranch($excepted_version_info['branch']);
- $this->assertInstanceOf(ModuleVersionParser::class, $parser);
- $this->assertSame($excepted_version_info['major'], $parser->getMajorVersion());
- $this->assertSame($excepted_version_info['minor'], $parser->getMinorVersion());
+ $version = ModuleVersion::createFromSupportBranch($excepted_version_info['branch']);
+ $this->assertInstanceOf(ModuleVersion::class, $version);
+ $this->assertSame($excepted_version_info['major'], $version->getMajorVersion());
+ $this->assertSame($excepted_version_info['minor'], $version->getMinorVersion());
// Version extra and Patch version can't be determined from a branch.
- $this->assertSame(NULL, $parser->getVersionExtra());
- $this->assertSame(NULL, $parser->getPatchVersion());
+ $this->assertSame(NULL, $version->getVersionExtra());
+ $this->assertSame(NULL, $version->getPatchVersion());
}
/**
diff --git a/core/modules/update/update.compare.inc b/core/modules/update/update.compare.inc
index cbf6cd6522..a65e20fca1 100644
--- a/core/modules/update/update.compare.inc
+++ b/core/modules/update/update.compare.inc
@@ -7,7 +7,7 @@
use Drupal\update\UpdateFetcherInterface;
use Drupal\update\UpdateManagerInterface;
-use Drupal\update\ModuleVersionParser;
+use Drupal\update\ModuleVersion;
/**
* Determines version and type information for currently installed projects.
@@ -237,14 +237,14 @@ function update_calculate_project_update_status(&$project_data, $available) {
}
// Figure out the target major version.
- $existing_version_parser = new ModuleVersionParser($project_data['existing_version']);
- $existing_major = $existing_version_parser->getMajorVersion();
+ $existing_module_version = new ModuleVersion($project_data['existing_version']);
+ $existing_major = $existing_module_version->getMajorVersion();
$supported_branches = [];
if (isset($available['supported_branches'])) {
$supported_branches = explode(',', $available['supported_branches']);
}
- if (in_array($existing_version_parser->getSupportBranch(), $supported_branches)) {
+ if (in_array($existing_module_version->getSupportBranch(), $supported_branches)) {
// Still supported, stay at the current major version.
$target_major = $existing_major;
}
@@ -252,7 +252,7 @@ function update_calculate_project_update_status(&$project_data, $available) {
// We know the current release is unsupported since it is not in
// 'supported_branches' list. We should use the next supported branch for
// the target major version.
- $target_major = ModuleVersionParser::createFromSupportBranch($supported_branches[0])->getMajorVersion();
+ $target_major = ModuleVersion::createFromSupportBranch($supported_branches[0])->getMajorVersion();
$project_data['status'] = UpdateManagerInterface::NOT_SUPPORTED;
}
else {
@@ -290,7 +290,7 @@ function update_calculate_project_update_status(&$project_data, $available) {
return;
}
foreach ($available['releases'] as $version => $release) {
- $release_version_parser = new ModuleVersionParser($release['version']);
+ $release_module_version = new ModuleVersion($release['version']);
// First, if this is the existing release, check a few conditions.
if ($project_data['existing_version'] === $version) {
if (isset($release['terms']['Release type']) &&
@@ -330,15 +330,15 @@ function update_calculate_project_update_status(&$project_data, $available) {
continue;
}
- $release_major_version = $release_version_parser->getMajorVersion();
- $release_patch_version = $release_version_parser->getPatchVersion();
+ $release_major_version = $release_module_version->getMajorVersion();
+ $release_patch_version = $release_module_version->getPatchVersion();
// See if this is a higher major version than our target and yet still
// supported. If so, record it as an "Also available" release.
// Note: Some projects have a HEAD release from CVS days, which could
// be one of those being compared. They would not have version_major
// set, so we must call isset first.
if ($release_major_version !== NULL && $release_major_version > $target_major) {
- if (in_array($release_version_parser->getSupportBranch(), $supported_branches)) {
+ if (in_array($release_module_version->getSupportBranch(), $supported_branches)) {
if (!isset($project_data['also'])) {
$project_data['also'] = [];
}
@@ -368,7 +368,7 @@ function update_calculate_project_update_status(&$project_data, $available) {
// Look for the development snapshot release for this branch.
if (!isset($project_data['dev_version'])
&& $release_major_version == $target_major
- && $release_version_parser->getVersionExtra() === 'dev') {
+ && $release_module_version->getVersionExtra() === 'dev') {
$project_data['dev_version'] = $version;
$project_data['releases'][$version] = $release;
}
@@ -382,7 +382,7 @@ function update_calculate_project_update_status(&$project_data, $available) {
$patch = $release_patch_version;
$release_patch_changed = $release;
}
- if ($release_version_parser->getVersionExtra() === NULL && $patch == $release_patch_version) {
+ if ($release_module_version->getVersionExtra() === NULL && $patch == $release_patch_version) {
$project_data['recommended'] = $release_patch_changed['version'];
$project_data['releases'][$release_patch_changed['version']] = $release_patch_changed;
}