Skip to content
Snippets Groups Projects
Commit 05ab8aea authored by Adam G-H's avatar Adam G-H
Browse files

Clean up summary

parent 5b8d0f67
No related branches found
No related tags found
1 merge request!312Issue #3275883: Warn if cron updates are enabled and the site is on an unsupported branch
...@@ -148,10 +148,19 @@ final class VersionPolicyValidator implements EventSubscriberInterface { ...@@ -148,10 +148,19 @@ final class VersionPolicyValidator implements EventSubscriberInterface {
$messages = $this->validateVersion($stage, $target_version); $messages = $this->validateVersion($stage, $target_version);
if ($messages) { if ($messages) {
$summary = $this->t('Updating from Drupal @installed_version to @target_version is not allowed.', [ $installed_version = $this->getInstalledVersion();
'@installed_version' => $this->getInstalledVersion(),
'@target_version' => $target_version, if ($target_version) {
]); $summary = $this->t('Updating from Drupal @installed_version to @target_version is not allowed.', [
'@installed_version' => $installed_version,
'@target_version' => $target_version,
]);
}
else {
$summary = $this->t('Updating from Drupal @installed_version is not allowed.', [
'@installed_version' => $installed_version,
]);
}
$event->addError($messages, $summary); $event->addError($messages, $summary);
} }
} }
......
...@@ -137,7 +137,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { ...@@ -137,7 +137,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase {
"$metadata_dir/drupal.9.8.1-security.xml", "$metadata_dir/drupal.9.8.1-security.xml",
[CronUpdater::SECURITY, CronUpdater::ALL], [CronUpdater::SECURITY, CronUpdater::ALL],
[ [
$this->createValidationResult('9.7.1', '', [ $this->createValidationResult('9.7.1', NULL, [
'The currently installed version of Drupal core, 9.7.1, is not in a supported minor version. Your site will not be automatically updated during cron until it is updated to a supported minor version.', 'The currently installed version of Drupal core, 9.7.1, is not in a supported minor version. Your site will not be automatically updated during cron until it is updated to a supported minor version.',
'See the <a href="/admin/reports/updates">available updates page</a> for available updates.', 'See the <a href="/admin/reports/updates">available updates page</a> for available updates.',
]), ]),
...@@ -148,7 +148,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { ...@@ -148,7 +148,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase {
"$metadata_dir/drupal.9.8.1-security.xml", "$metadata_dir/drupal.9.8.1-security.xml",
[CronUpdater::SECURITY, CronUpdater::ALL], [CronUpdater::SECURITY, CronUpdater::ALL],
[ [
$this->createValidationResult('9.7.1', '', [ $this->createValidationResult('9.7.1', NULL, [
'The currently installed version of Drupal core, 9.7.1, is not in a supported minor version. Your site will not be automatically updated during cron until it is updated to a supported minor version.', 'The currently installed version of Drupal core, 9.7.1, is not in a supported minor version. Your site will not be automatically updated during cron until it is updated to a supported minor version.',
'Use the <a href="/admin/modules/automatic-update">update form</a> to update to a supported version.', 'Use the <a href="/admin/modules/automatic-update">update form</a> to update to a supported version.',
]), ]),
...@@ -439,19 +439,26 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { ...@@ -439,19 +439,26 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase {
* *
* @param string $installed_version * @param string $installed_version
* The installed version of Drupal core. * The installed version of Drupal core.
* @param string $target_version * @param string|null $target_version
* The target version of Drupal core. * The target version of Drupal core, or NULL if it's not known.
* @param string[] $messages * @param string[] $messages
* The error messages that the result should contain. * The error messages that the result should contain.
* *
* @return \Drupal\package_manager\ValidationResult * @return \Drupal\package_manager\ValidationResult
* A validation error object with the appropriate summary. * A validation error object with the appropriate summary.
*/ */
private function createValidationResult(string $installed_version, string $target_version, array $messages): ValidationResult { private function createValidationResult(string $installed_version, ?string $target_version, array $messages): ValidationResult {
$summary = t('Updating from Drupal @installed_version to @target_version is not allowed.', [ if ($target_version) {
'@installed_version' => $installed_version, $summary = t('Updating from Drupal @installed_version to @target_version is not allowed.', [
'@target_version' => $target_version, '@installed_version' => $installed_version,
]); '@target_version' => $target_version,
]);
}
else {
$summary = t('Updating from Drupal @installed_version is not allowed.', [
'@installed_version' => $installed_version,
]);
}
return ValidationResult::createError($messages, $summary); return ValidationResult::createError($messages, $summary);
} }
......
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