From 11bb19bd4367ecd7671a983260e45e74fc8385b0 Mon Sep 17 00:00:00 2001 From: "Theresa.Grannum" <theresa.grannum@3688861.no-reply.drupal.org> Date: Wed, 29 Jun 2022 16:30:36 +0000 Subject: [PATCH] Issue #3286650 by Theresa.Grannum, tedbow: Drop support for Drupal 9.2 --- automatic_updates.info.yml | 3 +- .../automatic_updates_9_3_shim.info.yml | 5 - .../src/ProjectRelease.php | 288 ------------------ .../automatic_updates_extensions.info.yml | 2 +- composer.json | 2 +- package_manager/package_manager.info.yml | 2 +- src/CronUpdater.php | 4 +- src/Form/UpdaterForm.php | 4 +- src/ProjectInfo.php | 6 +- src/ReleaseChooser.php | 10 +- .../VersionPolicy/TargetSecurityRelease.php | 2 +- .../TargetVersionInstallable.php | 2 +- src/Validator/VersionPolicyValidator.php | 2 +- tests/src/Kernel/ReleaseChooserTest.php | 4 +- tests/src/Traits/VersionPolicyTestTrait.php | 2 +- .../TargetSecurityReleaseTest.php | 4 +- .../TargetVersionInstallableTest.php | 4 +- 17 files changed, 26 insertions(+), 320 deletions(-) delete mode 100644 automatic_updates_9_3_shim/automatic_updates_9_3_shim.info.yml delete mode 100644 automatic_updates_9_3_shim/src/ProjectRelease.php diff --git a/automatic_updates.info.yml b/automatic_updates.info.yml index 7269daf9a6..e6fee5ee29 100644 --- a/automatic_updates.info.yml +++ b/automatic_updates.info.yml @@ -1,9 +1,8 @@ name: 'Automatic Updates' type: module description: 'Automatically updates Drupal core.' -core_version_requirement: ^9.2 +core_version_requirement: ^9.3 lifecycle: experimental dependencies: - - drupal:automatic_updates_9_3_shim - drupal:package_manager - drupal:update diff --git a/automatic_updates_9_3_shim/automatic_updates_9_3_shim.info.yml b/automatic_updates_9_3_shim/automatic_updates_9_3_shim.info.yml deleted file mode 100644 index aed1b4bb79..0000000000 --- a/automatic_updates_9_3_shim/automatic_updates_9_3_shim.info.yml +++ /dev/null @@ -1,5 +0,0 @@ -name: 'Automatic Updates 9.3.x shim' -type: module -description: 'Shim module to allow using improvements to the Update module in 9.3.x' -core_version_requirement: ~9.2 -package: 'Security' diff --git a/automatic_updates_9_3_shim/src/ProjectRelease.php b/automatic_updates_9_3_shim/src/ProjectRelease.php deleted file mode 100644 index 9a157fd37a..0000000000 --- a/automatic_updates_9_3_shim/src/ProjectRelease.php +++ /dev/null @@ -1,288 +0,0 @@ -<?php - -namespace Drupal\automatic_updates_9_3_shim; - -use Symfony\Component\Validator\Constraints\Choice; -use Symfony\Component\Validator\Constraints\Collection; -use Symfony\Component\Validator\Constraints\NotBlank; -use Symfony\Component\Validator\Constraints\Optional; -use Symfony\Component\Validator\Constraints\Type; -use Symfony\Component\Validator\Validation; - -/** - * Provides a project release value object. - */ -final class ProjectRelease { - - /** - * Whether the release is compatible with the site's Drupal core version. - * - * @var bool - */ - private $coreCompatible; - - /** - * The core compatibility message or NULL if not set. - * - * @var string|null - */ - private $coreCompatibilityMessage; - - /** - * The download URL or NULL if none is available. - * - * @var string|null - */ - private $downloadUrl; - - /** - * The URL for the release. - * - * @var string - */ - private $releaseUrl; - - /** - * The release types or NULL if not set. - * - * @var string[]|null - */ - private $releaseTypes; - - /** - * Whether the release is published. - * - * @var bool - */ - private $published; - - /** - * The release version. - * - * @var string - */ - private $version; - - /** - * The release date as a Unix timestamp or NULL if no date was set. - * - * @var int|null - */ - private $date; - - /** - * Constructs a ProjectRelease object. - * - * @param bool $published - * Whether the release is published. - * @param string $version - * The release version. - * @param string $release_url - * The URL for the release. - * @param string[]|null $release_types - * The release types or NULL if not set. - * @param bool|null $core_compatible - * Whether the release is compatible with the site's version of Drupal core. - * @param string|null $core_compatibility_message - * The core compatibility message or NULL if not set. - * @param string|null $download_url - * The download URL or NULL if not available. - * @param int|null $date - * The release date in Unix timestamp format. - */ - private function __construct(bool $published, string $version, string $release_url, ?array $release_types, ?bool $core_compatible, ?string $core_compatibility_message, ?string $download_url, ?int $date) { - $this->published = $published; - $this->version = $version; - $this->releaseUrl = $release_url; - $this->releaseTypes = $release_types; - $this->coreCompatible = $core_compatible; - $this->coreCompatibilityMessage = $core_compatibility_message; - $this->downloadUrl = $download_url; - $this->date = $date; - } - - /** - * Creates a ProjectRelease instance from an array. - * - * @param array $release_data - * The project release data as returned by update_get_available(). - * - * @return \Drupal\update\ProjectRelease - * The ProjectRelease instance. - * - * @throws \UnexpectedValueException - * Thrown if project release data is not valid. - * - * @see \update_get_available() - */ - public static function createFromArray(array $release_data): ProjectRelease { - static::validateReleaseData($release_data); - return new ProjectRelease( - $release_data['status'] === 'published', - $release_data['version'], - $release_data['release_link'], - $release_data['terms']['Release type'] ?? NULL, - $release_data['core_compatible'] ?? NULL, - $release_data['core_compatibility_message'] ?? NULL, - $release_data['download_link'] ?? NULL, - $release_data['date'] ?? NULL - ); - } - - /** - * Validates the project release data. - * - * @param array $data - * The project release data. - * - * @throws \UnexpectedValueException - * Thrown if project release data is not valid. - */ - private static function validateReleaseData(array $data): void { - $not_blank_constraints = [ - new Type('string'), - new NotBlank(), - ]; - $collection_constraint = new Collection([ - 'fields' => [ - 'version' => $not_blank_constraints, - 'date' => new Optional([new Type('numeric')]), - 'core_compatible' => new Optional([new Type('boolean')]), - 'core_compatibility_message' => new Optional($not_blank_constraints), - 'status' => new Choice(['published', 'unpublished']), - 'download_link' => new Optional($not_blank_constraints), - 'release_link' => $not_blank_constraints, - 'terms' => new Optional([ - new Type('array'), - new Collection([ - 'Release type' => new Optional([ - new Type('array'), - ]), - ]), - ]), - ], - 'allowExtraFields' => TRUE, - ]); - $violations = Validation::createValidator()->validate($data, $collection_constraint); - if (count($violations)) { - foreach ($violations as $violation) { - $violation_messages[] = "Field " . $violation->getPropertyPath() . ": " . $violation->getMessage(); - } - throw new \UnexpectedValueException('Malformed release data: ' . implode(",\n", $violation_messages)); - } - } - - /** - * Gets the project version. - * - * @return string - * The project version. - */ - public function getVersion(): string { - return $this->version; - } - - /** - * Gets the release date if set. - * - * @return int|null - * The date of the release or null if no date is available. - */ - public function getDate(): ?int { - return $this->date; - } - - /** - * Determines if the release is a security release. - * - * @return bool - * TRUE if the release is security release, or FALSE otherwise. - */ - public function isSecurityRelease(): bool { - return $this->isReleaseType('Security update'); - } - - /** - * Determines if the release is unsupported. - * - * @return bool - * TRUE if the release is unsupported, or FALSE otherwise. - */ - public function isUnsupported(): bool { - return $this->isReleaseType('Unsupported'); - } - - /** - * Determines if the release is insecure. - * - * @return bool - * TRUE if the release is insecure, or FALSE otherwise. - */ - public function isInsecure(): bool { - return $this->isReleaseType('Insecure'); - } - - /** - * Determines if the release is matches a type. - * - * @param string $type - * The release type. - * - * @return bool - * TRUE if the release matches the type, or FALSE otherwise. - */ - private function isReleaseType(string $type): bool { - return $this->releaseTypes && in_array($type, $this->releaseTypes, TRUE); - } - - /** - * Determines if the release is published. - * - * @return bool - * TRUE if the release is published, or FALSE otherwise. - */ - public function isPublished(): bool { - return $this->published; - } - - /** - * Determines whether release is compatible the site's version of Drupal core. - * - * @return bool|null - * Whether the release is compatible or NULL if no data is set. - */ - public function isCoreCompatible(): ?bool { - return $this->coreCompatible; - } - - /** - * Gets the core compatibility message for the site's version of Drupal core. - * - * @return string|null - * The core compatibility message or NULL if none is available. - */ - public function getCoreCompatibilityMessage(): ?string { - return $this->coreCompatibilityMessage; - } - - /** - * Gets the download URL of the release. - * - * @return string|null - * The download URL or NULL if none is available. - */ - public function getDownloadUrl(): ?string { - return $this->downloadUrl; - } - - /** - * Gets the URL of the release. - * - * @return string - * The URL of the release. - */ - public function getReleaseUrl(): string { - return $this->releaseUrl; - } - -} diff --git a/automatic_updates_extensions/automatic_updates_extensions.info.yml b/automatic_updates_extensions/automatic_updates_extensions.info.yml index d6f2f0a89e..c2062382a3 100644 --- a/automatic_updates_extensions/automatic_updates_extensions.info.yml +++ b/automatic_updates_extensions/automatic_updates_extensions.info.yml @@ -1,7 +1,7 @@ name: 'Automatic Updates Extensions' type: module description: 'Allows updates to themes and modules' -core_version_requirement: ^9.2 +core_version_requirement: ^9.3 hidden: true lifecycle: experimental dependencies: diff --git a/composer.json b/composer.json index 904ae37d3a..db5f72ef81 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ }, "require": { "ext-json": "*", - "drupal/core": "^9.2", + "drupal/core": "^9.3", "php-tuf/composer-stager": "^1@beta", "composer/composer": "^2.2.12 || ^2.3.5", "composer-runtime-api": "^2.0.9" diff --git a/package_manager/package_manager.info.yml b/package_manager/package_manager.info.yml index 42ed1dc350..80185a8d5e 100644 --- a/package_manager/package_manager.info.yml +++ b/package_manager/package_manager.info.yml @@ -1,5 +1,5 @@ name: 'Package Manager' type: module description: 'API module providing functionality for staging package installs and updates with Composer.' -core_version_requirement: ^9 +core_version_requirement: ^9.3 lifecycle: experimental diff --git a/src/CronUpdater.php b/src/CronUpdater.php index d315d65d09..538e0c9bff 100644 --- a/src/CronUpdater.php +++ b/src/CronUpdater.php @@ -2,13 +2,13 @@ namespace Drupal\automatic_updates; -use Drupal\automatic_updates_9_3_shim\ProjectRelease; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Mail\MailManagerInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\Url; use Drupal\package_manager\Exception\StageValidationException; +use Drupal\update\ProjectRelease; use GuzzleHttp\Psr7\Uri as GuzzleUri; use Symfony\Component\HttpFoundation\Response; @@ -133,7 +133,7 @@ class CronUpdater extends Updater { /** * Returns the release of Drupal core to update to, if any. * - * @return \Drupal\automatic_updates_9_3_shim\ProjectRelease|null + * @return \Drupal\update\ProjectRelease|null * The release of Drupal core to which we will update, or NULL if there is * nothing to update to. */ diff --git a/src/Form/UpdaterForm.php b/src/Form/UpdaterForm.php index 95c8e96398..5b5b042219 100644 --- a/src/Form/UpdaterForm.php +++ b/src/Form/UpdaterForm.php @@ -8,7 +8,7 @@ use Drupal\automatic_updates\ProjectInfo; use Drupal\automatic_updates\ReleaseChooser; use Drupal\automatic_updates\Updater; use Drupal\automatic_updates\Validation\ReadinessTrait; -use Drupal\automatic_updates_9_3_shim\ProjectRelease; +use Drupal\update\ProjectRelease; use Drupal\Core\Batch\BatchBuilder; use Drupal\Core\Extension\ExtensionVersion; use Drupal\Core\Form\FormBase; @@ -341,7 +341,7 @@ final class UpdaterForm extends FormBase { /** * Gets the update table for a specific release. * - * @param \Drupal\automatic_updates_9_3_shim\ProjectRelease $release + * @param \Drupal\update\ProjectRelease $release * The project release. * @param string $release_description * The release description. diff --git a/src/ProjectInfo.php b/src/ProjectInfo.php index 79391b05af..075940b791 100644 --- a/src/ProjectInfo.php +++ b/src/ProjectInfo.php @@ -3,7 +3,7 @@ namespace Drupal\automatic_updates; use Composer\Semver\Comparator; -use Drupal\automatic_updates_9_3_shim\ProjectRelease; +use Drupal\update\ProjectRelease; use Drupal\Core\Extension\ExtensionVersion; use Drupal\update\UpdateManagerInterface; @@ -35,7 +35,7 @@ class ProjectInfo { /** * Determines if a release can be installed. * - * @param \Drupal\automatic_updates_9_3_shim\ProjectRelease $release + * @param \Drupal\update\ProjectRelease $release * The project release. * @param string[] $support_branches * The supported branches. @@ -80,7 +80,7 @@ class ProjectInfo { /** * Gets all project releases to which the site can update. * - * @return \Drupal\automatic_updates_9_3_shim\ProjectRelease[]|null + * @return \Drupal\update\ProjectRelease[]|null * If the project information is available, an array of releases that can be * installed, keyed by version number; otherwise NULL. The releases are in * descending order by version number (i.e., higher versions are listed diff --git a/src/ReleaseChooser.php b/src/ReleaseChooser.php index 0aad2c2c60..8bd89ac1ea 100644 --- a/src/ReleaseChooser.php +++ b/src/ReleaseChooser.php @@ -4,7 +4,7 @@ namespace Drupal\automatic_updates; use Composer\Semver\Semver; use Drupal\automatic_updates\Validator\VersionPolicyValidator; -use Drupal\automatic_updates_9_3_shim\ProjectRelease; +use Drupal\update\ProjectRelease; use Drupal\Core\Extension\ExtensionVersion; /** @@ -45,7 +45,7 @@ class ReleaseChooser { * @param \Drupal\automatic_updates\Updater $updater * The updater that will be used to install the releases. * - * @return \Drupal\automatic_updates_9_3_shim\ProjectRelease[] + * @return \Drupal\update\ProjectRelease[] * The releases that are installable by the given updtaer, according to the * version validator service. */ @@ -68,7 +68,7 @@ class ReleaseChooser { * @param string $version * The full semantic version number, which must include a patch version. * - * @return \Drupal\automatic_updates_9_3_shim\ProjectRelease|null + * @return \Drupal\update\ProjectRelease|null * The most recent release in the minor if available, otherwise NULL. * * @throws \InvalidArgumentException @@ -110,7 +110,7 @@ class ReleaseChooser { * @param \Drupal\automatic_updates\Updater $updater * The updater which will install the release. * - * @return \Drupal\automatic_updates_9_3_shim\ProjectRelease|null + * @return \Drupal\update\ProjectRelease|null * The latest release in the currently installed minor, if any, otherwise * NULL. */ @@ -127,7 +127,7 @@ class ReleaseChooser { * @param \Drupal\automatic_updates\Updater $updater * The updater which will install the release. * - * @return \Drupal\automatic_updates_9_3_shim\ProjectRelease|null + * @return \Drupal\update\ProjectRelease|null * The latest release in the next minor, if any, otherwise NULL. */ public function getLatestInNextMinor(Updater $updater): ?ProjectRelease { diff --git a/src/Validator/VersionPolicy/TargetSecurityRelease.php b/src/Validator/VersionPolicy/TargetSecurityRelease.php index b209e52b9b..61d2f0e3f4 100644 --- a/src/Validator/VersionPolicy/TargetSecurityRelease.php +++ b/src/Validator/VersionPolicy/TargetSecurityRelease.php @@ -23,7 +23,7 @@ class TargetSecurityRelease { * The installed version of Drupal. * @param string|null $target_version * The target version of Drupal, or NULL if not known. - * @param \Drupal\automatic_updates_9_3_shim\ProjectRelease[] $available_releases + * @param \Drupal\update\ProjectRelease[] $available_releases * The available releases of Drupal core. * * @return \Drupal\Core\StringTranslation\TranslatableMarkup[] diff --git a/src/Validator/VersionPolicy/TargetVersionInstallable.php b/src/Validator/VersionPolicy/TargetVersionInstallable.php index de38041869..586dd2a8f1 100644 --- a/src/Validator/VersionPolicy/TargetVersionInstallable.php +++ b/src/Validator/VersionPolicy/TargetVersionInstallable.php @@ -23,7 +23,7 @@ class TargetVersionInstallable { * The installed version of Drupal. * @param string|null $target_version * The target version of Drupal, or NULL if not known. - * @param \Drupal\automatic_updates_9_3_shim\ProjectRelease[] $available_releases + * @param \Drupal\update\ProjectRelease[] $available_releases * The available releases of Drupal core. * * @return \Drupal\Core\StringTranslation\TranslatableMarkup[] diff --git a/src/Validator/VersionPolicyValidator.php b/src/Validator/VersionPolicyValidator.php index ffcfbde711..b8f2feddfc 100644 --- a/src/Validator/VersionPolicyValidator.php +++ b/src/Validator/VersionPolicyValidator.php @@ -222,7 +222,7 @@ final class VersionPolicyValidator implements EventSubscriberInterface { * @param \Drupal\automatic_updates\Updater $updater * The updater which will perform the update. * - * @return \Drupal\automatic_updates_9_3_shim\ProjectRelease[] + * @return \Drupal\update\ProjectRelease[] * The available releases of Drupal core, keyed by version number and in * descending order (i.e., newest first). Will be in ascending order (i.e., * oldest first) if $updater is the cron updater. diff --git a/tests/src/Kernel/ReleaseChooserTest.php b/tests/src/Kernel/ReleaseChooserTest.php index 52d8e918bd..f158f7da52 100644 --- a/tests/src/Kernel/ReleaseChooserTest.php +++ b/tests/src/Kernel/ReleaseChooserTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\automatic_updates\Kernel; -use Drupal\automatic_updates_9_3_shim\ProjectRelease; +use Drupal\update\ProjectRelease; /** * @coversDefaultClass \Drupal\automatic_updates\ReleaseChooser @@ -156,7 +156,7 @@ class ReleaseChooserTest extends AutomaticUpdatesKernelTestBase { * * @param string|null $version * The version to check, or NULL if no version expected. - * @param \Drupal\automatic_updates_9_3_shim\ProjectRelease|null $release + * @param \Drupal\update\ProjectRelease|null $release * The release to check, or NULL if no release is expected. */ private function assertReleaseVersion(?string $version, ?ProjectRelease $release) { diff --git a/tests/src/Traits/VersionPolicyTestTrait.php b/tests/src/Traits/VersionPolicyTestTrait.php index c86355adcd..f294421b19 100644 --- a/tests/src/Traits/VersionPolicyTestTrait.php +++ b/tests/src/Traits/VersionPolicyTestTrait.php @@ -18,7 +18,7 @@ trait VersionPolicyTestTrait { * The target version of Drupal, or NULL if it's not known. * @param string[] $expected_errors * The expected error messages, if any. - * @param \Drupal\automatic_updates_9_3_shim\ProjectRelease[] $available_releases + * @param \Drupal\update\ProjectRelease[] $available_releases * (optional) The available releases of Drupal core, keyed by version. * Defaults to an empty array. */ diff --git a/tests/src/Unit/VersionPolicy/TargetSecurityReleaseTest.php b/tests/src/Unit/VersionPolicy/TargetSecurityReleaseTest.php index da1e31e7f9..437f6a2c57 100644 --- a/tests/src/Unit/VersionPolicy/TargetSecurityReleaseTest.php +++ b/tests/src/Unit/VersionPolicy/TargetSecurityReleaseTest.php @@ -3,7 +3,7 @@ namespace Drupal\Tests\automatic_updates\Unit\VersionPolicy; use Drupal\automatic_updates\Validator\VersionPolicy\TargetSecurityRelease; -use Drupal\automatic_updates_9_3_shim\ProjectRelease; +use Drupal\update\ProjectRelease; use Drupal\Tests\automatic_updates\Traits\VersionPolicyTestTrait; use Drupal\Tests\UnitTestCase; @@ -53,7 +53,7 @@ class TargetSecurityReleaseTest extends UnitTestCase { /** * Tests that the target version must be a security release. * - * @param \Drupal\automatic_updates_9_3_shim\ProjectRelease[] $available_releases + * @param \Drupal\update\ProjectRelease[] $available_releases * The available releases of Drupal core, keyed by version. * @param string[] $expected_errors * The expected error messages, if any. diff --git a/tests/src/Unit/VersionPolicy/TargetVersionInstallableTest.php b/tests/src/Unit/VersionPolicy/TargetVersionInstallableTest.php index ea3e16ee19..f1454ab4d9 100644 --- a/tests/src/Unit/VersionPolicy/TargetVersionInstallableTest.php +++ b/tests/src/Unit/VersionPolicy/TargetVersionInstallableTest.php @@ -3,7 +3,7 @@ namespace Drupal\Tests\automatic_updates\Unit\VersionPolicy; use Drupal\automatic_updates\Validator\VersionPolicy\TargetVersionInstallable; -use Drupal\automatic_updates_9_3_shim\ProjectRelease; +use Drupal\update\ProjectRelease; use Drupal\Tests\automatic_updates\Traits\VersionPolicyTestTrait; use Drupal\Tests\UnitTestCase; @@ -54,7 +54,7 @@ class TargetVersionInstallableTest extends UnitTestCase { /** * Tests that the target version must be a known, installable release. * - * @param \Drupal\automatic_updates_9_3_shim\ProjectRelease[] $available_releases + * @param \Drupal\update\ProjectRelease[] $available_releases * The available releases of Drupal core, keyed by version. * @param string[] $expected_errors * The expected error messages, if any. -- GitLab