Skip to content
Snippets Groups Projects

Issue #3311472 Set minimum stability for form

1 unresolved thread
Files
5
@@ -4,7 +4,8 @@ declare(strict_types = 1);
namespace Drupal\automatic_updates\Validator\VersionPolicy;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Composer\Semver\VersionParser;
use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* A policy rule requiring the target version to be a RC or higher.
@@ -14,20 +15,30 @@ use Drupal\Core\StringTranslation\TranslatableMarkup;
* Drupal core. It may be changed or removed at any time without warning.
* External code should not interact with this class.
*/
final class TargetVersionNotPreRelease extends TargetVersionStabilityBase {
final class TargetVersionNotPreRelease {
/**
* {@inheritdoc}
*/
protected string $minimumStability = 'rc';
use StringTranslationTrait;
/**
* {@inheritdoc}
* Checks that the target version of Drupal is a stable release.
*
* @param string $installed_version
* The installed version of Drupal.
* @param string|null $target_version
* The target version of Drupal, or NULL if not known.
*
* @return \Drupal\Core\StringTranslation\TranslatableMarkup[]
* The error messages, if any.
*/
protected function getErrorMessage(string $target_version): TranslatableMarkup {
return $this->t('Drupal cannot be updated to the recommended version, @target_version, because it is pre-release version.', [
'@target_version' => $target_version,
]);
public function validate(string $installed_version, ?string $target_version): array {
if (!in_array(VersionParser::parseStability($target_version), ['stable', 'RC'], TRUE)) {
return [
$this->t('Drupal cannot be automatically updated during cron to the recommended version, @target_version, because it is not a stable version.', [
'@target_version' => $target_version,
]),
];
}
return [];
}
}
Loading