From 2c214a7559b014c711cc82cd89256fb1e068403b Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 15 Dec 2014 17:15:04 +0000 Subject: [PATCH] Issue #2387627 by olli: Changing access plugins in views leaves invalid settings around --- core/modules/user/src/Tests/Views/AccessRoleUITest.php | 8 ++++++++ .../views/src/Plugin/views/display/DisplayPluginBase.php | 2 ++ 2 files changed, 10 insertions(+) diff --git a/core/modules/user/src/Tests/Views/AccessRoleUITest.php b/core/modules/user/src/Tests/Views/AccessRoleUITest.php index 70a797dd5a9..55cd88691ba 100644 --- a/core/modules/user/src/Tests/Views/AccessRoleUITest.php +++ b/core/modules/user/src/Tests/Views/AccessRoleUITest.php @@ -56,6 +56,14 @@ class AccessRoleUITest extends UITestBase { $display = $view->getDisplay('default'); $this->assertEqual($display['display_options']['access']['options']['role'], array('custom_role' => 'custom_role')); + + // Test changing access plugin from role to none. + $this->drupalPostForm('admin/structure/views/nojs/display/test_access_role/default/access', ['access[type]' => 'none'], t('Apply')); + $this->drupalPostForm(NULL, array(), t('Save')); + // Verify that role option is not set. + $view = $entity_manager->getStorage('view')->load('test_access_role'); + $display = $view->getDisplay('default'); + $this->assertFalse(isset($display['display_options']['access']['options']['role'])); } } diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 13ff1681cf1..a0ff4acfafd 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -1994,6 +1994,7 @@ abstract class DisplayPluginBase extends PluginBase { $plugin_options = $this->getOption($plugin_type); $type = $form_state->getValue(array($plugin_type, 'type')); if ($plugin_options['type'] != $type) { + /** @var \Drupal\views\Plugin\views\ViewsPluginInterface $plugin */ $plugin = Views::pluginManager($plugin_type)->createInstance($type); if ($plugin) { $plugin->init($this->view, $this, $plugin_options['options']); @@ -2001,6 +2002,7 @@ abstract class DisplayPluginBase extends PluginBase { 'type' => $type, 'options' => $plugin->options, ); + $plugin->filterByDefinedOptions($plugin_options['options']); $this->setOption($plugin_type, $plugin_options); if ($plugin->usesOptions()) { $form_state->get('view')->addFormToStack('display', $this->display['id'], $plugin_type . '_options');