diff --git a/core/lib/Drupal/Core/Form/FormCache.php b/core/lib/Drupal/Core/Form/FormCache.php index 3b7f706..92ab026 100644 --- a/core/lib/Drupal/Core/Form/FormCache.php +++ b/core/lib/Drupal/Core/Form/FormCache.php @@ -230,7 +230,6 @@ public function setCache($form_build_id, $form, FormStateInterface $form_state) */ public function deleteCache($form_build_id) { $this->keyValueExpirableFactory->get('form')->delete($form_build_id); - $this->keyValueExpirableFactory->get('form_state')->delete($form_build_id); $session = $this->requestStack->getMasterRequest()->getSession(); $session->remove('form_state:' . $form_build_id); } diff --git a/core/modules/dblog/src/Tests/DbLogFormInjectionTest.php b/core/modules/dblog/src/Tests/DbLogFormInjectionTest.php index e622fe2..81b9725 100644 --- a/core/modules/dblog/src/Tests/DbLogFormInjectionTest.php +++ b/core/modules/dblog/src/Tests/DbLogFormInjectionTest.php @@ -92,6 +92,9 @@ protected function setUp() { )); $test_user->save(); \Drupal::service('current_user')->setAccount($test_user); + $session = \Drupal::service('session'); + \Drupal::request()->setSession($session); + $session->start(); } /** diff --git a/core/modules/system/src/Tests/Form/FormCacheTest.php b/core/modules/system/src/Tests/Form/FormCacheTest.php index 77d259e..7d5b86d 100644 --- a/core/modules/system/src/Tests/Form/FormCacheTest.php +++ b/core/modules/system/src/Tests/Form/FormCacheTest.php @@ -52,6 +52,9 @@ protected function setUp() { ); $this->formState = new FormState(); $this->formState->set('example', $this->randomMachineName()); + $session = \Drupal::service('session'); + \Drupal::request()->setSession($session); + $session->start(); } /** diff --git a/core/modules/system/src/Tests/Queue/QueueSerializationTest.php b/core/modules/system/src/Tests/Queue/QueueSerializationTest.php index 9108ac2..56acbb5 100644 --- a/core/modules/system/src/Tests/Queue/QueueSerializationTest.php +++ b/core/modules/system/src/Tests/Queue/QueueSerializationTest.php @@ -90,6 +90,9 @@ protected function setUp() { )); $test_user->save(); \Drupal::service('current_user')->setAccount($test_user); + $session = \Drupal::service('session'); + \Drupal::request()->setSession($session); + $session->start(); } /** diff --git a/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php b/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php index 36f1146..cc31a7e 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php @@ -301,7 +301,7 @@ public function testLoadCachedFormState() { $this->session->expects($this->once()) ->method('get') ->with('form_state:' . $form_build_id) - ->willReturn(['data' => $cached_form_state, 'expires' => $this->requestTime + 604800]); + ->willReturn(serialize(['data' => $cached_form_state, 'expires' => $this->requestTime + 604800])); $this->formCache->getCache($form_build_id, $form_state); $this->assertSame($cached_form_state['storage'], $form_state->getStorage()); @@ -346,7 +346,7 @@ public function testLoadCachedFormStateWithFiles() { $this->session->expects($this->once()) ->method('get') ->with('form_state:' . $form_build_id) - ->willReturn(['data' => $cached_form_state, 'expires' => $this->requestTime + 604800]); + ->willReturn(serialize(['data' => $cached_form_state, 'expires' => $this->requestTime + 604800])); $this->formCache->getCache($form_build_id, $form_state); } @@ -378,7 +378,7 @@ public function testLoadCachedFormStateWithSafeStrings() { $this->session->expects($this->once()) ->method('get') ->with('form_state:' . $form_build_id) - ->willReturn(['data' => $cached_form_state, 'expires' => $this->requestTime + 604800]); + ->willReturn(serialize(['data' => $cached_form_state, 'expires' => $this->requestTime + 604800])); $this->formCache->getCache($form_build_id, $form_state); } @@ -401,7 +401,7 @@ public function testSetCacheWithForm() { $form_state_data['build_info']['safe_strings'] = []; $this->session->expects($this->once()) ->method('set') - ->with('form_state:' . $form_build_id, ['expires' => $this->requestTime + 21600, 'data' => $form_state_data]); + ->with('form_state:' . $form_build_id, serialize(['expires' => $this->requestTime + 21600, 'data' => $form_state_data])); $this->formCache->setCache($form_build_id, $form, $form_state); } @@ -421,7 +421,7 @@ public function testSetCacheWithoutForm() { $form_state_data['build_info']['safe_strings'] = []; $this->session->expects($this->once()) ->method('set') - ->with('form_state:' . $form_build_id, ['expires' => $this->requestTime + 21600, 'data' => $form_state_data]); + ->with('form_state:' . $form_build_id, serialize(['expires' => $this->requestTime + 21600, 'data' => $form_state_data])); $this->formCache->setCache($form_build_id, $form, $form_state); } @@ -445,7 +445,7 @@ public function testSetCacheAuthUser() { $form_state_data['build_info']['safe_strings'] = []; $this->session->expects($this->once()) ->method('set') - ->with('form_state:' . $form_build_id, ['expires' => $this->requestTime + 21600, 'data' => $form_state_data]); + ->with('form_state:' . $form_build_id, serialize(['expires' => $this->requestTime + 21600, 'data' => $form_state_data])); $this->csrfToken->expects($this->once()) ->method('get') @@ -478,7 +478,7 @@ public function testSetCacheWithSafeStrings() { ]; $this->session->expects($this->once()) ->method('set') - ->with('form_state:' . $form_build_id, ['expires' => $this->requestTime + 21600, 'data' => $form_state_data]); + ->with('form_state:' . $form_build_id, serialize(['expires' => $this->requestTime + 21600, 'data' => $form_state_data])); $this->formCache->setCache($form_build_id, $form, $form_state); } @@ -514,9 +514,7 @@ public function testDeleteCache() { $this->formCacheStore->expects($this->once()) ->method('delete') ->with($form_build_id); - $this->formStateCacheStore->expects($this->once()) - ->method('delete') - ->with($form_build_id); + $this->formCache->deleteCache($form_build_id); }