diff -u b/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php b/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php --- b/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php +++ b/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php @@ -76,10 +76,9 @@ // the configured upload limit. if ($exception instanceof BrokenPostRequestException && $request->query->has(FormBuilderInterface::AJAX_FORM_REQUEST)) { $this->drupalSetMessage($this->t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', ['@size' => $this->formatSize($exception->getSize())]), 'error'); - $response = new AjaxResponse(); + $response = new AjaxResponse(NULL, 200); $status_messages = ['#type' => 'status_messages']; $response->addCommand(new PrependCommand(NULL, $status_messages)); - $response->headers->set('Status-Code', 200); $event->allowCustomResponseCode(); $event->setResponse($response); return; @@ -100,8 +99,8 @@ // Since this response is being set in place of an exception, explicitly // mark this as a 200 status. - $response->headers->set('Status-Code', 200); - $event->allowCustomStatusCode(); + $response->setStatusCode(200); + $event->allowCustomResponseCode(); $event->setResponse($response); } catch (\Exception $e) { diff -u b/core/tests/Drupal/Tests/Component/Serialization/YamlTest.php b/core/tests/Drupal/Tests/Component/Serialization/YamlTest.php --- b/core/tests/Drupal/Tests/Component/Serialization/YamlTest.php +++ b/core/tests/Drupal/Tests/Component/Serialization/YamlTest.php @@ -12,7 +12,6 @@ /** * @coversDefaultClass \Drupal\Component\Serialization\Yaml * @group Serialization - * @group legacy */ class YamlTest extends TestCase { @@ -78,13 +77,13 @@ } /** - * Ensures that decoding php objects is similar for PECL and Symfony. + * Ensures that decoding php objects does not work in PECL. * * @requires extension yaml * - * @expectedDeprecation Using the unquoted scalar value "!php/object "O:8:\"stdClass\":1:{s:3:\"foo\";s:3:\"bar\";}"" is deprecated since version 3.3 and will be considered as a tagged value in 4.0. You must quote it on line 2. + * @see \Drupal\Tests\Component\Serialization\YamlTest::testObjectSupportDisabledSymfony() */ - public function testObjectSupportDisabled() { + public function testObjectSupportDisabledPecl() { $object = new \stdClass(); $object->foo = 'bar'; // In core all Yaml encoding is done via Symfony and it does not support @@ -93,7 +92,25 @@ // @see \Drupal\Component\Serialization\Yaml::encode() $yaml = YamlPecl::encode([$object]); $this->assertEquals(['O:8:"stdClass":1:{s:3:"foo";s:3:"bar";}'], YamlPecl::decode($yaml)); - $this->assertEquals(['!php/object "O:8:\"stdClass\":1:{s:3:\"foo\";s:3:\"bar\";}"'], YamlSymfony::decode($yaml)); + } + + /** + * Ensures that decoding php objects does not work in Symfony. + * + * @requires extension yaml + * + * @see \Drupal\Tests\Component\Serialization\YamlTest::testObjectSupportDisabledPecl() + */ + public function testObjectSupportDisabledSymfony() { + $this->setExpectedExceptionRegExp(InvalidDataTypeException::class, '/^Object support when parsing a YAML file has been disabled/'); + $object = new \stdClass(); + $object->foo = 'bar'; + // In core all Yaml encoding is done via Symfony and it does not support + // objects so in order to encode an object we hace to use the PECL + // extension. + // @see \Drupal\Component\Serialization\Yaml::encode() + $yaml = YamlPecl::encode([$object]); + YamlSymfony::decode($yaml); } /** diff -u b/core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php b/core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php --- b/core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php +++ b/core/tests/Drupal/Tests/Core/Form/EventSubscriber/FormAjaxSubscriberTest.php @@ -76,7 +76,8 @@ ->willReturn($response); $event = $this->assertResponseFromException($request, $exception, $response); - $this->assertSame(200, $event->getResponse()->headers->get('Status-Code')); + $this->assertTrue($event->isAllowingCustomResponseCode()); + $this->assertSame(200, $event->getResponse()->getStatusCode()); } /** @@ -100,7 +101,8 @@ ->willReturn($response); $event = $this->assertResponseFromException($request, $exception, $response); - $this->assertSame(200, $event->getResponse()->headers->get('Status-Code')); + $this->assertTrue($event->isAllowingCustomResponseCode()); + $this->assertSame(200, $event->getResponse()->getStatusCode()); } /** @@ -176,9 +178,10 @@ $event = new GetResponseForExceptionEvent($this->httpKernel, $request, HttpKernelInterface::MASTER_REQUEST, $exception); $this->subscriber->onException($event); + $this->assertTrue($event->isAllowingCustomResponseCode()); $actual_response = $event->getResponse(); $this->assertInstanceOf('\Drupal\Core\Ajax\AjaxResponse', $actual_response); - $this->assertSame(200, $actual_response->headers->get('Status-Code')); + $this->assertSame(200, $actual_response->getStatusCode()); $expected_commands[] = [ 'command' => 'insert', 'method' => 'prepend', diff -u b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php --- b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php +++ b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php @@ -50,7 +50,7 @@ * * @group legacy * - * @expectedDeprecation The "Symfony\Component\HttpFoundation\Request::setTrustedHeaderName()" method is deprecated since version 3.3 and will be removed in 4.0. Use the $trustedHeaderSet argument of the Request::setTrustedProxies() method instead. + * @expectedDeprecation The "Symfony\Component\HttpFoundation\Request::setTrustedHeaderName()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the $trustedHeaderSet argument of the Request::setTrustedProxies() method instead. */ public function testReverseProxyEnabled($provided_settings) { // Enable reverse proxy and add test values. diff -u b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php --- b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php @@ -279,14 +279,12 @@ "The 'rest.entity.workflow.GET.json' route is deprecated since version 8.5.x and will be removed in 9.0.0. Use the 'rest.entity.workflow.GET' route instead.", "The 'rest.entity.workflow.GET.xml' route is deprecated since version 8.5.x and will be removed in 9.0.0. Use the 'rest.entity.workflow.GET' route instead.", "The 'rest.entity.workflow.GET.hal_json' route is deprecated since version 8.5.x and will be removed in 9.0.0. Use the 'rest.entity.workflow.GET' route instead.", - 'Using the unquoted scalar value "!php/object "O:8:\"stdClass\":1:{s:3:\"foo\";s:3:\"bar\";}"" is deprecated since version 3.3 and will be considered as a tagged value in 4.0. You must quote it.', 'The Symfony\Component\ClassLoader\ApcClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', - 'Using the X-Status-Code header is deprecated since Symfony 3.3 and will be removed in 4.0. Use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent::allowCustomResponseCode() instead.', 'The Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead.', - 'Not setting the strict option of the Choice constraint to true is deprecated since Symfony 3.4 and will throw an exception in 4.0.', 'The Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler class is deprecated since Symfony 3.4 and will be removed in 4.0. Implement `SessionUpdateTimestampHandlerInterface` or extend `AbstractSessionHandler` instead.', - 'Using the Yaml::PARSE_KEYS_AS_STRINGS flag is deprecated since Symfony 3.4 as it will be removed in 4.0. Quote your keys when they are evaluable instead.', 'The "session_handler.write_check" service relies on the deprecated "Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler" class. It should either be deprecated or its implementation upgraded.', + 'Not setting the strict option of the Choice constraint to true is deprecated since Symfony 3.4 and will throw an exception in 4.0.', + 'Using the Yaml::PARSE_KEYS_AS_STRINGS flag is deprecated since Symfony 3.4 as it will be removed in 4.0. Quote your keys when they are evaluable instead.', ]; }