diff --git a/core/modules/update/src/ModuleVersionParser.php b/core/modules/update/src/ModuleVersionParser.php index f365125227..4ae563a443 100644 --- a/core/modules/update/src/ModuleVersionParser.php +++ b/core/modules/update/src/ModuleVersionParser.php @@ -24,6 +24,22 @@ public function __construct($version) { $this->version = $version; } + /** + * Constructs a module version parser from a support branch. + * + * This can be used to determine the major and minor versions. The patch + * version will always be 'x'. + * + * @param string $branch + * The support branch. + * + * @return \Drupal\update\ModuleVersionParser + * The module version parser. + */ + public static function createFromSupportBranch($branch) { + return new static ($branch . 'x'); + } + /** * Gets the major version. * diff --git a/core/modules/update/update.compare.inc b/core/modules/update/update.compare.inc index 5ef9053f8c..9b6c4193ee 100644 --- a/core/modules/update/update.compare.inc +++ b/core/modules/update/update.compare.inc @@ -123,12 +123,14 @@ function update_calculate_project_data($available) { * with an error and the next project is considered. * * If the project itself is valid, the function decides what major release - * series to consider. The project defines what the currently supported major - * versions are for each version of core, so the first step is to make sure the - * current version is still supported. If so, that's the target version. If the - * current version is unsupported, the project maintainer's recommended major - * version is used. There's also a check to make sure that this function never - * recommends an earlier release than the currently installed major version. + * series to consider. The project defines the currently supported development + * branches, so the first step is to make sure the development branch of the + * current version is still supported. If so, then the major version of the + * current version is used. If the current + * version is not in supported branch, the project maintainer's recommended + * branch is used to determine the major version to use. There's also a check to + * make sure that this function never recommends an earlier release than the + * currently installed major version. * * Given a target major version, the available releases are scanned looking for * the specific release to recommend (avoiding beta releases and development @@ -247,12 +249,11 @@ function update_calculate_project_update_status(&$project_data, $available) { // Still supported, stay at the current major version. $target_major = $existing_major; } - elseif (isset($available['recommended_branch'])) { - // We know the current release is unsupported since - // its major version was not in the 'supported_branches' list. We should - // find the best release from the recommended major version. - $branch_version_parser = new ModuleVersionParser($available['recommended_branch'] . 'x'); - $target_major = $branch_version_parser->getMajorVersion(); + elseif ($supported_branches) { + // 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(); $project_data['status'] = UpdateManagerInterface::NOT_SUPPORTED; } else {