Skip to content
Snippets Groups Projects
Commit 11bb19bd authored by Theresa Grannum's avatar Theresa Grannum Committed by Adam G-H
Browse files

Issue #3286650 by Theresa.Grannum, tedbow: Drop support for Drupal 9.2

parent 3275c03e
No related branches found
No related tags found
No related merge requests found
Showing
with 26 additions and 320 deletions
name: 'Automatic Updates' name: 'Automatic Updates'
type: module type: module
description: 'Automatically updates Drupal core.' description: 'Automatically updates Drupal core.'
core_version_requirement: ^9.2 core_version_requirement: ^9.3
lifecycle: experimental lifecycle: experimental
dependencies: dependencies:
- drupal:automatic_updates_9_3_shim
- drupal:package_manager - drupal:package_manager
- drupal:update - drupal:update
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'
<?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;
}
}
name: 'Automatic Updates Extensions' name: 'Automatic Updates Extensions'
type: module type: module
description: 'Allows updates to themes and modules' description: 'Allows updates to themes and modules'
core_version_requirement: ^9.2 core_version_requirement: ^9.3
hidden: true hidden: true
lifecycle: experimental lifecycle: experimental
dependencies: dependencies:
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
}, },
"require": { "require": {
"ext-json": "*", "ext-json": "*",
"drupal/core": "^9.2", "drupal/core": "^9.3",
"php-tuf/composer-stager": "^1@beta", "php-tuf/composer-stager": "^1@beta",
"composer/composer": "^2.2.12 || ^2.3.5", "composer/composer": "^2.2.12 || ^2.3.5",
"composer-runtime-api": "^2.0.9" "composer-runtime-api": "^2.0.9"
......
name: 'Package Manager' name: 'Package Manager'
type: module type: module
description: 'API module providing functionality for staging package installs and updates with Composer.' description: 'API module providing functionality for staging package installs and updates with Composer.'
core_version_requirement: ^9 core_version_requirement: ^9.3
lifecycle: experimental lifecycle: experimental
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
namespace Drupal\automatic_updates; namespace Drupal\automatic_updates;
use Drupal\automatic_updates_9_3_shim\ProjectRelease;
use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Mail\MailManagerInterface; use Drupal\Core\Mail\MailManagerInterface;
use Drupal\Core\State\StateInterface; use Drupal\Core\State\StateInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\package_manager\Exception\StageValidationException; use Drupal\package_manager\Exception\StageValidationException;
use Drupal\update\ProjectRelease;
use GuzzleHttp\Psr7\Uri as GuzzleUri; use GuzzleHttp\Psr7\Uri as GuzzleUri;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
...@@ -133,7 +133,7 @@ class CronUpdater extends Updater { ...@@ -133,7 +133,7 @@ class CronUpdater extends Updater {
/** /**
* Returns the release of Drupal core to update to, if any. * 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 * The release of Drupal core to which we will update, or NULL if there is
* nothing to update to. * nothing to update to.
*/ */
......
...@@ -8,7 +8,7 @@ use Drupal\automatic_updates\ProjectInfo; ...@@ -8,7 +8,7 @@ use Drupal\automatic_updates\ProjectInfo;
use Drupal\automatic_updates\ReleaseChooser; use Drupal\automatic_updates\ReleaseChooser;
use Drupal\automatic_updates\Updater; use Drupal\automatic_updates\Updater;
use Drupal\automatic_updates\Validation\ReadinessTrait; 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\Batch\BatchBuilder;
use Drupal\Core\Extension\ExtensionVersion; use Drupal\Core\Extension\ExtensionVersion;
use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormBase;
...@@ -341,7 +341,7 @@ final class UpdaterForm extends FormBase { ...@@ -341,7 +341,7 @@ final class UpdaterForm extends FormBase {
/** /**
* Gets the update table for a specific release. * 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. * The project release.
* @param string $release_description * @param string $release_description
* The release description. * The release description.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Drupal\automatic_updates; namespace Drupal\automatic_updates;
use Composer\Semver\Comparator; use Composer\Semver\Comparator;
use Drupal\automatic_updates_9_3_shim\ProjectRelease; use Drupal\update\ProjectRelease;
use Drupal\Core\Extension\ExtensionVersion; use Drupal\Core\Extension\ExtensionVersion;
use Drupal\update\UpdateManagerInterface; use Drupal\update\UpdateManagerInterface;
...@@ -35,7 +35,7 @@ class ProjectInfo { ...@@ -35,7 +35,7 @@ class ProjectInfo {
/** /**
* Determines if a release can be installed. * Determines if a release can be installed.
* *
* @param \Drupal\automatic_updates_9_3_shim\ProjectRelease $release * @param \Drupal\update\ProjectRelease $release
* The project release. * The project release.
* @param string[] $support_branches * @param string[] $support_branches
* The supported branches. * The supported branches.
...@@ -80,7 +80,7 @@ class ProjectInfo { ...@@ -80,7 +80,7 @@ class ProjectInfo {
/** /**
* Gets all project releases to which the site can update. * 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 * If the project information is available, an array of releases that can be
* installed, keyed by version number; otherwise NULL. The releases are in * installed, keyed by version number; otherwise NULL. The releases are in
* descending order by version number (i.e., higher versions are listed * descending order by version number (i.e., higher versions are listed
......
...@@ -4,7 +4,7 @@ namespace Drupal\automatic_updates; ...@@ -4,7 +4,7 @@ namespace Drupal\automatic_updates;
use Composer\Semver\Semver; use Composer\Semver\Semver;
use Drupal\automatic_updates\Validator\VersionPolicyValidator; use Drupal\automatic_updates\Validator\VersionPolicyValidator;
use Drupal\automatic_updates_9_3_shim\ProjectRelease; use Drupal\update\ProjectRelease;
use Drupal\Core\Extension\ExtensionVersion; use Drupal\Core\Extension\ExtensionVersion;
/** /**
...@@ -45,7 +45,7 @@ class ReleaseChooser { ...@@ -45,7 +45,7 @@ class ReleaseChooser {
* @param \Drupal\automatic_updates\Updater $updater * @param \Drupal\automatic_updates\Updater $updater
* The updater that will be used to install the releases. * 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 * The releases that are installable by the given updtaer, according to the
* version validator service. * version validator service.
*/ */
...@@ -68,7 +68,7 @@ class ReleaseChooser { ...@@ -68,7 +68,7 @@ class ReleaseChooser {
* @param string $version * @param string $version
* The full semantic version number, which must include a patch 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. * The most recent release in the minor if available, otherwise NULL.
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
...@@ -110,7 +110,7 @@ class ReleaseChooser { ...@@ -110,7 +110,7 @@ class ReleaseChooser {
* @param \Drupal\automatic_updates\Updater $updater * @param \Drupal\automatic_updates\Updater $updater
* The updater which will install the release. * 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 * The latest release in the currently installed minor, if any, otherwise
* NULL. * NULL.
*/ */
...@@ -127,7 +127,7 @@ class ReleaseChooser { ...@@ -127,7 +127,7 @@ class ReleaseChooser {
* @param \Drupal\automatic_updates\Updater $updater * @param \Drupal\automatic_updates\Updater $updater
* The updater which will install the release. * 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. * The latest release in the next minor, if any, otherwise NULL.
*/ */
public function getLatestInNextMinor(Updater $updater): ?ProjectRelease { public function getLatestInNextMinor(Updater $updater): ?ProjectRelease {
......
...@@ -23,7 +23,7 @@ class TargetSecurityRelease { ...@@ -23,7 +23,7 @@ class TargetSecurityRelease {
* The installed version of Drupal. * The installed version of Drupal.
* @param string|null $target_version * @param string|null $target_version
* The target version of Drupal, or NULL if not known. * 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. * The available releases of Drupal core.
* *
* @return \Drupal\Core\StringTranslation\TranslatableMarkup[] * @return \Drupal\Core\StringTranslation\TranslatableMarkup[]
......
...@@ -23,7 +23,7 @@ class TargetVersionInstallable { ...@@ -23,7 +23,7 @@ class TargetVersionInstallable {
* The installed version of Drupal. * The installed version of Drupal.
* @param string|null $target_version * @param string|null $target_version
* The target version of Drupal, or NULL if not known. * 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. * The available releases of Drupal core.
* *
* @return \Drupal\Core\StringTranslation\TranslatableMarkup[] * @return \Drupal\Core\StringTranslation\TranslatableMarkup[]
......
...@@ -222,7 +222,7 @@ final class VersionPolicyValidator implements EventSubscriberInterface { ...@@ -222,7 +222,7 @@ final class VersionPolicyValidator implements EventSubscriberInterface {
* @param \Drupal\automatic_updates\Updater $updater * @param \Drupal\automatic_updates\Updater $updater
* The updater which will perform the update. * 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 * 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., * descending order (i.e., newest first). Will be in ascending order (i.e.,
* oldest first) if $updater is the cron updater. * oldest first) if $updater is the cron updater.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace Drupal\Tests\automatic_updates\Kernel; namespace Drupal\Tests\automatic_updates\Kernel;
use Drupal\automatic_updates_9_3_shim\ProjectRelease; use Drupal\update\ProjectRelease;
/** /**
* @coversDefaultClass \Drupal\automatic_updates\ReleaseChooser * @coversDefaultClass \Drupal\automatic_updates\ReleaseChooser
...@@ -156,7 +156,7 @@ class ReleaseChooserTest extends AutomaticUpdatesKernelTestBase { ...@@ -156,7 +156,7 @@ class ReleaseChooserTest extends AutomaticUpdatesKernelTestBase {
* *
* @param string|null $version * @param string|null $version
* The version to check, or NULL if no version expected. * 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. * The release to check, or NULL if no release is expected.
*/ */
private function assertReleaseVersion(?string $version, ?ProjectRelease $release) { private function assertReleaseVersion(?string $version, ?ProjectRelease $release) {
......
...@@ -18,7 +18,7 @@ trait VersionPolicyTestTrait { ...@@ -18,7 +18,7 @@ trait VersionPolicyTestTrait {
* The target version of Drupal, or NULL if it's not known. * The target version of Drupal, or NULL if it's not known.
* @param string[] $expected_errors * @param string[] $expected_errors
* The expected error messages, if any. * 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. * (optional) The available releases of Drupal core, keyed by version.
* Defaults to an empty array. * Defaults to an empty array.
*/ */
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Drupal\Tests\automatic_updates\Unit\VersionPolicy; namespace Drupal\Tests\automatic_updates\Unit\VersionPolicy;
use Drupal\automatic_updates\Validator\VersionPolicy\TargetSecurityRelease; 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\automatic_updates\Traits\VersionPolicyTestTrait;
use Drupal\Tests\UnitTestCase; use Drupal\Tests\UnitTestCase;
...@@ -53,7 +53,7 @@ class TargetSecurityReleaseTest extends UnitTestCase { ...@@ -53,7 +53,7 @@ class TargetSecurityReleaseTest extends UnitTestCase {
/** /**
* Tests that the target version must be a security release. * 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. * The available releases of Drupal core, keyed by version.
* @param string[] $expected_errors * @param string[] $expected_errors
* The expected error messages, if any. * The expected error messages, if any.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Drupal\Tests\automatic_updates\Unit\VersionPolicy; namespace Drupal\Tests\automatic_updates\Unit\VersionPolicy;
use Drupal\automatic_updates\Validator\VersionPolicy\TargetVersionInstallable; 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\automatic_updates\Traits\VersionPolicyTestTrait;
use Drupal\Tests\UnitTestCase; use Drupal\Tests\UnitTestCase;
...@@ -54,7 +54,7 @@ class TargetVersionInstallableTest extends UnitTestCase { ...@@ -54,7 +54,7 @@ class TargetVersionInstallableTest extends UnitTestCase {
/** /**
* Tests that the target version must be a known, installable release. * 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. * The available releases of Drupal core, keyed by version.
* @param string[] $expected_errors * @param string[] $expected_errors
* The expected error messages, if any. * The expected error messages, if any.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment