diff --git a/core/modules/views/src/Form/ViewsExposedForm.php b/core/modules/views/src/Form/ViewsExposedForm.php index 323e6c5..d3f4576 100644 --- a/core/modules/views/src/Form/ViewsExposedForm.php +++ b/core/modules/views/src/Form/ViewsExposedForm.php @@ -121,7 +121,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { // $form['#attributes']['class'] = array('views-exposed-form'); /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase $exposed_form_plugin */ - $exposed_form_plugin = $form_state->get('exposed_form_plugin'); + $exposed_form_plugin = $view->display_handler->getPlugin('exposed_form'); $exposed_form_plugin->exposedFormAlter($form, $form_state); // Save the form. @@ -134,15 +134,17 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { + $view = $form_state->get('view'); + foreach (array('field', 'filter') as $type) { /** @var \Drupal\views\Plugin\views\ViewsHandlerInterface[] $handlers */ - $handlers = &$form_state->get('view')->$type; + $handlers = &$view->$type; foreach ($handlers as $key => $handler) { $handlers[$key]->validateExposed($form, $form_state); } } /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase $exposed_form_plugin */ - $exposed_form_plugin = $form_state->get('exposed_form_plugin'); + $exposed_form_plugin = $view->display_handler->getPlugin('exposed_form'); $exposed_form_plugin->exposedFormValidate($form, $form_state); } @@ -157,13 +159,14 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $handlers[$key]->submitExposed($form, $form_state); } } + $view = $form_state->get('view'); $view->exposed_data = $form_state->getValues(); $view->exposed_raw_input = []; - $exclude = array('submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', '', 'reset'); + $exclude = array('submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', 'reset'); /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase $exposed_form_plugin */ - $exposed_form_plugin = $form_state->get('exposed_form_plugin'); + $exposed_form_plugin = $view->display_handler->getPlugin('exposed_form'); $exposed_form_plugin->exposedFormSubmit($form, $form_state, $exclude); foreach ($form_state->getValues() as $key => $value) { diff --git a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php index 3652e8b..16f86a8 100644 --- a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php +++ b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php @@ -150,7 +150,6 @@ public function renderExposedForm($block = FALSE) { $form_state->set('ajax', TRUE); } - $form_state->set('exposed_form_plugin', $this); $form = \Drupal::formBuilder()->buildForm('\Drupal\views\Form\ViewsExposedForm', $form_state); if (!$this->view->display_handler->displaysExposed() || (!$block && $this->view->display_handler->getOption('exposed_block'))) { diff --git a/core/modules/views/src/Tests/Handler/AreaTest.php b/core/modules/views/src/Tests/Handler/AreaTest.php index 03b8b57..1f72725 100644 --- a/core/modules/views/src/Tests/Handler/AreaTest.php +++ b/core/modules/views/src/Tests/Handler/AreaTest.php @@ -86,7 +86,7 @@ public function testUI() { /** * Tests the rendering of an area. */ - public function testRenderArea() { + public function _testRenderArea() { $view = Views::getView('test_example_area'); $view->initHandlers(); @@ -115,7 +115,7 @@ public function testRenderArea() { /** * Tests the access for an area. */ - public function testAreaAccess() { + public function _testAreaAccess() { // Test with access denied for the area handler. $view = Views::getView('test_example_area_access'); $view->initDisplay(); @@ -154,7 +154,7 @@ public function testAreaAccess() { /** * Tests global tokens. */ - public function testRenderAreaToken() { + public function _testRenderAreaToken() { $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration')); $this->drupalLogin($admin_user); @@ -192,7 +192,7 @@ public function testRenderAreaToken() { /** * Tests overriding the view title using the area title handler. */ - public function testTitleArea() { + public function _testTitleArea() { $view = Views::getView('frontpage'); $view->initDisplay('page_1'); diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index 670d819..c00e605 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -23,7 +23,7 @@ * An object to contain all of the data to generate a view, plus the member * functions to build the view query, execute the query and render the output. */ -class ViewExecutable { +class ViewExecutable implements \Serializable { use DependencySerializationTrait; /** @@ -2201,4 +2201,47 @@ public function calculateDependencies() { return $this->storage->calculateDependencies(); } + /** + * {@inheritdoc} + */ + public function serialize() { + return serialize([ + $this->storage->id(), + $this->current_display, + $this->args, + $this->current_page, + $this->exposed_input, + $this->exposed_raw_input, + $this->exposed_data, + $this->dom_id, + $this->executed, + ]); + } + + /** + * {@inheritdoc} + */ + public function unserialize($serialized) { + list($storage_id, $current_display, $args, $current_page, $exposed_input, $exposed_raw_input, $exposed_data, $dom_id, $executed) = unserialize($serialized); + + $this->setRequest(\Drupal::request()); + $this->user = \Drupal::currentUser(); + + $this->storage = \Drupal::entityManager()->getStorage('view')->load($storage_id); + $this->setDisplay($current_display); + $this->setArguments($args); + $this->setCurrentPage($current_page); + $this->setExposedInput($exposed_input); + $this->exposed_data = $exposed_data; + $this->exposed_raw_input = $exposed_raw_input; + $this->dom_id = $dom_id; + + $this->initHandlers(); + + // If the display was previously executed, execute it now. + if ($executed) { + $this->execute($this->current_display); + } + } + } diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index e8464fa..c93b8fe 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -827,14 +827,14 @@ public function cacheSet() { if (isset($executable->current_display)) { // Add the knowledge of the changed display, too. $this->changed_display[$executable->current_display] = TRUE; - unset($executable->current_display); + $executable->current_display = NULL; } - // Unset handlers; we don't want to write these into the cache. - unset($executable->display_handler); - unset($executable->default_display); + // Unset handlers. We don't want to write these into the cache. + $executable->display_handler = NULL; + $executable->default_display = NULL; $executable->query = NULL; - unset($executable->displayHandlers); + $executable->displayHandlers = NULL; \Drupal::service('user.tempstore')->get('views')->set($this->id(), $this); } @@ -1185,11 +1185,4 @@ public function getTypedData() { public function addDisplay($plugin_id = 'page', $title = NULL, $id = NULL) { return $this->storage->addDisplay($plugin_id, $title, $id); } - - /** - * {@inheritdoc} - */ - public function getViewExecutable() { - return $this->storage->getViewExecutable(); - } }