Commit 99e07773 authored by alexpott's avatar alexpott

Issue #2475715 by stefan.r, tstoeckler: Module uninstall form does not...

Issue #2475715 by stefan.r, tstoeckler: Module uninstall form does not validate correctly and breaks the confirmation form after 60 seconds
parent f08e28ad
......@@ -135,6 +135,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
// Prevent this page from showing when the module list is empty.
if (empty($this->modules)) {
drupal_set_message($this->t('The selected modules could not be uninstalled, either due to a website problem or due to the uninstall confirmation form timing out. Please try again.'), 'error');
return $this->redirect('system.modules_uninstall');
}
......
......@@ -171,7 +171,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
public function validateForm(array &$form, FormStateInterface $form_state) {
// Form submitted, but no modules selected.
if (!array_filter($form_state->getValue('uninstall'))) {
drupal_set_message($this->t('No modules selected.'), 'error');
$form_state->setErrorByName('uninstall', $this->t('No modules selected.'));
$form_state->setRedirect('system.modules_uninstall');
}
}
......@@ -184,7 +184,9 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$modules = $form_state->getValue('uninstall');
$uninstall = array_keys(array_filter($modules));
$account = $this->currentUser()->id();
$this->keyValueExpirable->setWithExpire($account, $uninstall, 60);
// Store the values for 6 hours. This expiration time is also used in
// the form cache.
$this->keyValueExpirable->setWithExpire($account, $uninstall, 6*60*60);
// Redirect to the confirm form.
$form_state->setRedirect('system.modules_uninstall_confirm');
......
......@@ -106,6 +106,10 @@ function testUninstallPage() {
// Make sure our unique cache entry is gone.
$cached = \Drupal::cache()->get('uninstall_test');
$this->assertFalse($cached, 'Cache entry not found');
// Make sure we get an error message when we try to confirm uninstallation
// of an empty list of modules.
$this->drupalGet('admin/modules/uninstall/confirm');
$this->assertText(t('The selected modules could not be uninstalled, either due to a website problem or due to the uninstall confirmation form timing out. Please try again.'), 'Module uninstall confirmation form displays error message');
// Make sure confirmation page is accessible only during uninstall process.
$this->drupalGet('admin/modules/uninstall/confirm');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment