Issue #2475715 by stefan.r, tstoeckler: Module uninstall form does not validate correctly and breaks the confirmation form after 60 seconds
parent
f08e28adc9
commit
99e0777322
|
@ -135,6 +135,7 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase {
|
|||
|
||||
// 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 @@ class ModulesUninstallForm extends FormBase {
|
|||
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 @@ class ModulesUninstallForm extends FormBase {
|
|||
$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 @@ class UninstallTest extends WebTestBase {
|
|||
// 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');
|
||||
|
|
Loading…
Reference in New Issue