diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index 13229f4..64786a8 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -38,8 +38,17 @@ public function parse($filename) { $parsed_info['version'] = $this->getDrupalVersion(); } elseif (strpos($parsed_info['version'], 'VERSION-') === 0) { - list($version, ) = explode('-', $this->getDrupalVersion()); - $parsed_info['version'] = $version . substr($parsed_info['version'], 7); + $drupal_version = $this->getDrupalVersion(); + list($version, ) = explode('-', $drupal_version); + $version = $version . substr($parsed_info['version'], 7); + // If the stability version of Drupal core is lower, use its version. + // Therefore if core's version is 8.1.x-alpha and the module's version + // is VERSION-beta in the info.yml file the displayed version with be + // 8.1.x-alpha. + if (version_compare($drupal_version, $version) < 0) { + $version = $drupal_version; + } + $parsed_info['version'] = $version; } } } diff --git a/core/tests/Drupal/Tests/Core/Extension/InfoParserDynamicTest.php b/core/tests/Drupal/Tests/Core/Extension/InfoParserDynamicTest.php index 47a4c60..8ff54df 100644 --- a/core/tests/Drupal/Tests/Core/Extension/InfoParserDynamicTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/InfoParserDynamicTest.php @@ -62,6 +62,8 @@ public function versionReplacementProvider() { ['VERSION-dev', '8.0.x-beta12', '8.0.x-dev'], ['VERSION-beta', '8.2.0', '8.2.0-beta'], ['VERSION', '8.5.0', '8.5.0'], + // If the stability version of Drupal core is lower then it is used. + ['VERSION-beta', '8.2.0-alpha', '8.2.0-alpha'], ['Blah VERSION', '8.1.0-rc2', 'Blah VERSION'], ['Blah VERSION-rc', '8.1.0-rc2', 'Blah VERSION-rc'], ];