Skip to content
Snippets Groups Projects

Issue #3276072: UpdateReleaseValidator doesn't handle legacy version numbers

Files
7
@@ -4,6 +4,7 @@ namespace Drupal\automatic_updates_extensions\Validator;
use Drupal\automatic_updates\ProjectInfo;
use Drupal\automatic_updates_extensions\ExtensionUpdater;
use Drupal\automatic_updates_extensions\LegacyVersionUtility;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\package_manager\Event\PreCreateEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -31,18 +32,38 @@ class UpdateReleaseValidator implements EventSubscriberInterface {
$all_versions = $stage->getPackageVersions();
$messages = [];
foreach (['production', 'dev'] as $package_type) {
foreach ($all_versions[$package_type] as $package_name => $version) {
foreach ($all_versions[$package_type] as $package_name => $sematic_version) {
$package_parts = explode('/', $package_name);
$project_name = $package_parts[1];
// If the version isn't in the list of installable releases, then it
// isn't secure and supported and the user should receive an error.
$releases = (new ProjectInfo($project_name))->getInstallableReleases();
if (empty($releases) || !array_key_exists($version, $releases)) {
$is_missing_version = FALSE;
if (empty($releases)) {
$is_missing_version = TRUE;
}
elseif (!array_key_exists($sematic_version, $releases)) {
$legacy_version = LegacyVersionUtility::convertToLegacyVersion($sematic_version);
if ($legacy_version) {
if (!array_key_exists($legacy_version, $releases)) {
// If we cannot find the version using semantic or legacy then the
// version is missing.
$is_missing_version = TRUE;
}
}
else {
// If we cannot convert the semantic version into a legacy version
// then the version is missing.
$is_missing_version = TRUE;
}
}
if ($is_missing_version) {
$messages[] = $this->t('Project @project_name to version @version', [
'@project_name' => $project_name,
'@version' => $version,
'@version' => $sematic_version,
]);
}
}
}
if ($messages) {
Loading