diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index 89b0178..11b5e4c 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -683,7 +683,7 @@ public function prepareForm($form_id, &$form, &$form_state) { } // For certain forms like a search for or exposed filters, we want to make // a clean GET request without hidden values as query parameters. - if ($form['#method'] == 'get' && ($form['#token'] === FALSE || !empty($form_state['always_process']))) { + if ($form['#method'] == 'get' && !empty($form['#clean_get'])) { $clean_get = TRUE; $form['#token'] = FALSE; } diff --git a/core/modules/views/lib/Drupal/views/Form/ViewsExposedForm.php b/core/modules/views/lib/Drupal/views/Form/ViewsExposedForm.php index fcb6cab..11e3b88 100644 --- a/core/modules/views/lib/Drupal/views/Form/ViewsExposedForm.php +++ b/core/modules/views/lib/Drupal/views/Form/ViewsExposedForm.php @@ -119,7 +119,7 @@ public function buildForm(array $form, array &$form_state) { // Since the exposed form is a GET form, we don't want it to send a wide // variety of information. - $form['#token'] = FALSE; + $form['#clean_get'] = TRUE; // $form['#attributes']['class'] = array('views-exposed-form'); /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase $exposed_form_plugin */ diff --git a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php index f66a1db..6328627 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php @@ -328,8 +328,7 @@ public function testPrepareFormGetWithTokenChecking() { /** * Tests the prepareForm() method with a get request without token checking. * - * You can explicitly remove form token checking by using #token = FALSE or - * by setting $form_state['always_process'] = TRUE when using get. + * You can explicitly remove form token checking by using #clean_get = TRUE */ public function testPrepareFormGetWithoutTokenChecking() { $form = array(); @@ -339,7 +338,7 @@ public function testPrepareFormGetWithoutTokenChecking() { $form_state += $this->formBuilder->getFormStateDefaults(); $form = (new TestForm())->buildForm($form, $form_state); // Opt out of the token checking. - $form['#token'] = FALSE; + $form['#clean_get'] = TRUE; $this->formBuilder->prepareForm('my_module_form_id', $form, $form_state); @@ -352,7 +351,7 @@ public function testPrepareFormGetWithoutTokenChecking() { $form_state = $this->formBuilder->getFormStateDefaults(); $form = (new TestForm())->buildForm($form, $form_state); // Opt out of the token checking. - $form['#token'] = FALSE; + $form['#clean_get'] = TRUE; $form['#method'] = 'get'; $this->formBuilder->prepareForm('my_module_form_id2', $form, $form_state); @@ -361,20 +360,6 @@ public function testPrepareFormGetWithoutTokenChecking() { $this->assertFalse(isset($form['form_build_id'])); $this->assertFalse(isset($form['form_id'])); $this->assertFalse(isset($form['form_token'])); - - // Third variant. - $form_state = array( - 'method' => 'get', - 'always_process' => TRUE, - ); - $form = (new TestForm())->buildForm($form, $form_state); - - $this->formBuilder->prepareForm('my_module_form_id3', $form, $form_state); - - $this->assertEquals('get', $form['#method']); - $this->assertFalse(isset($form['form_build_id'])); - $this->assertFalse(isset($form['form_id'])); - $this->assertFalse(isset($form['form_token'])); } /**