diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php index 65c1106..a3a9bbb 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php @@ -29,11 +29,11 @@ class ModulesListConfirmForm extends ConfirmFormBase implements ControllerInterf protected $moduleHandler; /** - * The key value expirable factory service. + * The expirable key value store. * - * @var \Drupal\Core\KeyValueStore\KeyValueExpirableFactory + * @var \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface */ - protected $keyValueExpirableFactory; + protected $keyValueExpirable; /** * The translation manager service. @@ -82,7 +82,7 @@ public static function create(ContainerInterface $container) { */ public function __construct(ModuleHandlerInterface $module_handler, KeyValueExpirableFactory $key_value_expirable_factory, TranslationManager $translation_manager, Request $request) { $this->moduleHandler = $module_handler; - $this->keyValueExpirableFactory = $key_value_expirable_factory; + $this->keyValueExpirable = $key_value_expirable_factory->get('module_list'); $this->translationManager = $translation_manager; $this->request = $request; } @@ -105,7 +105,7 @@ public function getCancelPath() { * {@inheritdoc} */ public function getConfirmText() { - return t('Continue'); + return $this->translationManager->translate('Continue'); } /** @@ -127,9 +127,7 @@ public function getFormID() { */ public function buildForm(array $form, array &$form_state) { $account = $this->request->attributes->get('account')->id(); - $this->modules = $this->keyValueExpirableFactory - ->get('modules_list_install') - ->get($account); + $this->modules = $this->keyValueExpirable->get($account); // Redirect to the modules list page if the key value store is empty. if (!$this->modules) { @@ -167,26 +165,27 @@ public function buildForm(array $form, array &$form_state) { public function submitForm(array &$form, array &$form_state) { // Remove the key value store entry. $account = $this->request->attributes->get('account')->id(); - $this->keyValueExpirableFactory - ->get('modules_list_install') - ->delete($account); - - if ($form_state['values']['confirm'] && $this->modules) { - // Installs, enables, and disables modules. - if (!empty($this->modules['enable'])) { - $this->moduleHandler->enable(array_keys($this->modules['enable'])); - } - if (!empty($this->modules['disable'])) { - $this->moduleHandler->disable(array_keys($this->modules['disable'])); - } - - // Gets module list after install process, flushes caches and displays a - // message if there are changes. + $this->keyValueExpirable->delete($account); + + // Gets list of modules prior to install process. + $before = $this->moduleHandler->getModuleList(); + + // Installs, enables, and disables modules. + if (!empty($this->modules['enable'])) { + $this->moduleHandler->enable(array_keys($this->modules['enable'])); + } + if (!empty($this->modules['disable'])) { + $this->moduleHandler->disable(array_keys($this->modules['disable'])); + } + + // Gets module list after install process, flushes caches and displays a + // message if there are changes. + if ($before != $this->moduleHandler->getModuleList()) { drupal_flush_all_caches(); drupal_set_message(t('The configuration options have been saved.')); - - $form_state['redirect'] = 'admin/modules'; } + + $form_state['redirect'] = $this->getCancelPath(); } } diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php index a396a21..74b37cb 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php @@ -34,11 +34,11 @@ class ModulesListForm implements FormInterface, ControllerInterface { protected $moduleHandler; /** - * The key value expirable factory service. + * The expirable key value store. * - * @var \Drupal\Core\KeyValueStore\KeyValueExpirableFactory + * @var \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface */ - protected $keyValueExpirableFactory; + protected $keyValueExpirable; /** * The translation manager service. @@ -55,13 +55,6 @@ class ModulesListForm implements FormInterface, ControllerInterface { protected $request; /** - * An associative list of modules to enable or disable. - * - * @var array - */ - protected $modules = array(); - - /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { @@ -87,7 +80,7 @@ public static function create(ContainerInterface $container) { */ public function __construct(ModuleHandlerInterface $module_handler, KeyValueExpirableFactory $key_value_expirable_factory, TranslationManager $translation_manager, Request $request) { $this->moduleHandler = $module_handler; - $this->keyValueExpirableFactory = $key_value_expirable_factory; + $this->keyValueExpirable = $key_value_expirable_factory->get('module_list'); $this->translationManager = $translation_manager; $this->request = $request; } @@ -432,9 +425,7 @@ public function submitForm(array &$form, array &$form_state) { if (!empty($modules['dependencies']) || !empty($modules['missing'])) { // Write the list of changed module states into a key value store. $account = $this->request->attributes->get('account')->id(); - $this->keyValueExpirableFactory - ->get('modules_list_install') - ->setWithExpire($account, $modules, 60); + $this->keyValueExpirable->setWithExpire($account, $modules, 60); // Redirect to the confirmation form. $form_state['redirect'] = 'admin/modules/list/confirm'; @@ -444,9 +435,12 @@ public function submitForm(array &$form, array &$form_state) { return; } + // Gets list of modules prior to install process. + $before = $this->moduleHandler->getModuleList(); + // There seem to be no dependencies that would need approval. if (!empty($modules['enable'])) { - $this->moduleHandler->enable(array_keys($modules['enable'])); + $this->moduleHandler->enable(array_keys($modules['enable']), FALSE); } if (!empty($modules['disable'])) { $this->moduleHandler->disable(array_keys($modules['disable'])); @@ -454,8 +448,10 @@ public function submitForm(array &$form, array &$form_state) { // Gets module list after install process, flushes caches and displays a // message if there are changes. - drupal_flush_all_caches(); - drupal_set_message(t('The configuration options have been saved.')); + if ($before != $this->moduleHandler->getModuleList()) { + drupal_flush_all_caches(); + drupal_set_message(t('The configuration options have been saved.')); + } } }