function ProjectCoreCompatibility::getPossibleCoreUpdateVersions
Same name and namespace in other branches
- 11.x core/modules/update/src/ProjectCoreCompatibility.php \Drupal\update\ProjectCoreCompatibility::getPossibleCoreUpdateVersions()
- 10 core/modules/update/src/ProjectCoreCompatibility.php \Drupal\update\ProjectCoreCompatibility::getPossibleCoreUpdateVersions()
- 9 core/modules/update/src/ProjectCoreCompatibility.php \Drupal\update\ProjectCoreCompatibility::getPossibleCoreUpdateVersions()
- 8.9.x core/modules/update/src/ProjectCoreCompatibility.php \Drupal\update\ProjectCoreCompatibility::getPossibleCoreUpdateVersions()
Gets the core versions that should be considered for compatibility ranges.
Parameters
array $core_releases: The Drupal core available releases.
array $supported_branches: An array for supported branches as returned by drupal.org update XML.
Return value
string[] The core version numbers that are possible to update the site to.
1 call to ProjectCoreCompatibility::getPossibleCoreUpdateVersions()
- ProjectCoreCompatibility::__construct in core/
modules/ update/ src/ ProjectCoreCompatibility.php - Constructs a ProjectCoreCompatibility object.
File
-
core/
modules/ update/ src/ ProjectCoreCompatibility.php, line 82
Class
- ProjectCoreCompatibility
- Utility class to set core compatibility messages for project releases.
Namespace
Drupal\updateCode
protected function getPossibleCoreUpdateVersions(array $core_releases, array $supported_branches) {
if (!isset($core_releases[$this->existingCoreVersion])) {
// If we can't determine the existing version of core then we can't
// calculate the core compatibility of a given release based on core
// versions after the existing version.
return [];
}
$version_parser = new VersionParser();
$supported_versions = array_filter(array_keys($core_releases), function ($version) use ($supported_branches, $version_parser) {
// Filter out invalid semantic versions from external sources.
try {
$version_parser->normalize($version);
} catch (\UnexpectedValueException) {
return FALSE;
}
foreach ($supported_branches as $supported_branch) {
if (strpos($version, $supported_branch) === 0) {
return TRUE;
}
}
return FALSE;
});
try {
$possible_core_update_versions = Semver::satisfiedBy($supported_versions, '>= ' . $this->existingCoreVersion);
$possible_core_update_versions = Semver::sort($possible_core_update_versions);
} catch (\UnexpectedValueException) {
return [];
}
$possible_core_update_versions = array_filter($possible_core_update_versions, function ($version) {
return VersionParser::parseStability($version) === 'stable';
});
return $possible_core_update_versions;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.