Skip to content
Snippets Groups Projects
Commit 3275c03e authored by Theresa Grannum's avatar Theresa Grannum Committed by Ted Bowman
Browse files

Issue #3292027 by Theresa.Grannum: Warning users in...

Issue #3292027 by Theresa.Grannum: Warning users in automatic_updates_extensions about pending DB updates
parent 364fc900
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
namespace Drupal\automatic_updates_extensions\Form;
use Drupal\automatic_updates\Validator\StagedDatabaseUpdateValidator;
use Drupal\automatic_updates_extensions\BatchProcessor;
use Drupal\automatic_updates\BatchProcessor as AutoUpdatesBatchProcessor;
use Drupal\automatic_updates_extensions\ExtensionUpdater;
......@@ -44,6 +45,13 @@ final class UpdateReady extends FormBase {
*/
protected $moduleList;
/**
* The staged database update validator service.
*
* @var \Drupal\automatic_updates\Validator\StagedDatabaseUpdateValidator
*/
protected $stagedDatabaseUpdateValidator;
/**
* Constructs a new UpdateReady object.
*
......@@ -55,12 +63,15 @@ final class UpdateReady extends FormBase {
* The state service.
* @param \Drupal\Core\Extension\ModuleExtensionList $module_list
* The module list service.
* @param \Drupal\automatic_updates\Validator\StagedDatabaseUpdateValidator $staged_database_update_validator
* The staged database update validator service.
*/
public function __construct(ExtensionUpdater $updater, MessengerInterface $messenger, StateInterface $state, ModuleExtensionList $module_list) {
public function __construct(ExtensionUpdater $updater, MessengerInterface $messenger, StateInterface $state, ModuleExtensionList $module_list, StagedDatabaseUpdateValidator $staged_database_update_validator) {
$this->updater = $updater;
$this->setMessenger($messenger);
$this->state = $state;
$this->moduleList = $module_list;
$this->stagedDatabaseUpdateValidator = $staged_database_update_validator;
}
/**
......@@ -79,6 +90,7 @@ final class UpdateReady extends FormBase {
$container->get('messenger'),
$container->get('state'),
$container->get('extension.list.module'),
$container->get('automatic_updates.validator.staged_database_updates')
);
}
......@@ -96,11 +108,16 @@ final class UpdateReady extends FormBase {
$messages = [];
// @todo Add logic to warn about possible new database updates. Determine if
// \Drupal\automatic_updates\Validator\StagedDatabaseUpdateValidator
// should be duplicated or changed so that it can work with other stages.
// @see \Drupal\automatic_updates\Validator\StagedDatabaseUpdateValidator
// @see \Drupal\automatic_updates\Form\UpdateReady::buildForm()
// If there are any installed extension with database updates in the staging
// area, warn the user that they might be sent to update.php once the staged
// changes have been applied.
$pending_updates = $this->stagedDatabaseUpdateValidator->getExtensionsWithDatabaseUpdates($this->updater);
if ($pending_updates) {
$messages[MessengerInterface::TYPE_WARNING][] = $this->t('Possible database updates were detected in the following extensions; you may be redirected to the database update page in order to complete the update process.');
foreach ($pending_updates as $pending_update) {
$messages[MessengerInterface::TYPE_WARNING][] = $pending_update;
}
}
// Don't set any messages if the form has been submitted, because we don't
// want them to be set during form submit.
......
......@@ -145,6 +145,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
// Package Manager is bypassed.
$this->disableValidators(['automatic_updates.validator.scaffold_file_permissions']);
$this->container->get('theme_installer')->install(['automatic_updates_theme_with_updates']);
$this->updateProject = $project_name;
$this->setReleaseMetadata(__DIR__ . '/../../../../tests/fixtures/release-history/drupal.9.8.2.xml');
$this->setReleaseMetadata(__DIR__ . "/../../fixtures/release-history/$project_name.1.1.xml");
......@@ -168,9 +169,15 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
$this->assertUpdateStagedTimes(1);
// Confirm that the site was put into maintenance mode if needed.
$this->assertSame($state->get('system.maintenance_mode'), $maintenance_mode_on);
$assert_session = $this->assertSession();
$possible_update_message = 'Possible database updates were detected in the following extensions; you may be redirected to the database update page in order to complete the update process.';
$assert_session->pageTextContains($possible_update_message);
$assert_session->pageTextContainsOnce('System');
$assert_session->pageTextContainsOnce('Automatic Updates Theme With Updates');
$page->pressButton('Continue');
$this->checkForMetaRefresh();
$assert_session = $this->assertSession();
$assert_session->addressEquals('/admin/reports/updates');
// Confirm that the site was in maintenance before the update was applied.
// @see \Drupal\package_manager_test_validation\EventSubscriber\TestSubscriber::handleEvent()
......
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