diff --git a/core/lib/Drupal/Core/PageCache/DefaultRequestPolicy.php b/core/lib/Drupal/Core/PageCache/DefaultRequestPolicy.php index 4616d98..47d396f 100644 --- a/core/lib/Drupal/Core/PageCache/DefaultRequestPolicy.php +++ b/core/lib/Drupal/Core/PageCache/DefaultRequestPolicy.php @@ -2,7 +2,7 @@ namespace Drupal\Core\PageCache; -use Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod; +use Drupal\Core\PageCache\RequestPolicy\CommandLineOrUncacheableMethod; use Drupal\Core\PageCache\RequestPolicy\NoSessionOpen; use Drupal\Core\Session\SessionConfigurationInterface; @@ -22,7 +22,7 @@ class DefaultRequestPolicy extends ChainRequestPolicy { * The session configuration. */ public function __construct(SessionConfigurationInterface $session_configuration) { - $this->addPolicy(new CommandLineOrUnsafeMethod()); + $this->addPolicy(new CommandLineOrUncacheableMethod()); $this->addPolicy(new NoSessionOpen($session_configuration)); } diff --git a/core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUnsafeMethod.php b/core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUncacheableMethod.php similarity index 90% rename from core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUnsafeMethod.php rename to core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUncacheableMethod.php index 27a1f71..ccc76ce 100644 --- a/core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUnsafeMethod.php +++ b/core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUncacheableMethod.php @@ -12,7 +12,7 @@ * interface (drush) or the request method is neither GET nor HEAD (see RFC * 2616, section 9.1.1 - Safe Methods). */ -class CommandLineOrUnsafeMethod implements RequestPolicyInterface { +class CommandLineOrUncacheableMethod implements RequestPolicyInterface { /** * {@inheritdoc} diff --git a/core/modules/dynamic_page_cache/src/PageCache/RequestPolicy/DefaultRequestPolicy.php b/core/modules/dynamic_page_cache/src/PageCache/RequestPolicy/DefaultRequestPolicy.php index 7b894a6..8b4249c 100644 --- a/core/modules/dynamic_page_cache/src/PageCache/RequestPolicy/DefaultRequestPolicy.php +++ b/core/modules/dynamic_page_cache/src/PageCache/RequestPolicy/DefaultRequestPolicy.php @@ -3,7 +3,7 @@ namespace Drupal\dynamic_page_cache\PageCache\RequestPolicy; use Drupal\Core\PageCache\ChainRequestPolicy; -use Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod; +use Drupal\Core\PageCache\RequestPolicy\CommandLineOrUncacheableMethod; /** * The default Dynamic Page Cache request policy. @@ -18,7 +18,7 @@ class DefaultRequestPolicy extends ChainRequestPolicy { * Constructs the default Dynamic Page Cache request policy. */ public function __construct() { - $this->addPolicy(new CommandLineOrUnsafeMethod()); + $this->addPolicy(new CommandLineOrUncacheableMethod()); } } diff --git a/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php b/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php index b4bdedc..34dff52 100644 --- a/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php +++ b/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php @@ -96,7 +96,7 @@ public function getResponseFormat(RouteMatchInterface $route_match, Request $req $route = $route_match->getRouteObject(); $acceptable_request_formats = $route->hasRequirement('_format') ? explode('|', $route->getRequirement('_format')) : []; $acceptable_content_type_formats = $route->hasRequirement('_content_type_format') ? explode('|', $route->getRequirement('_content_type_format')) : []; - $acceptable_formats = $request->isMethodCacheable() ? $acceptable_request_formats : $acceptable_content_type_formats; + $acceptable_formats = $request->isMethodSafe() ? $acceptable_request_formats : $acceptable_content_type_formats; $requested_format = $request->getRequestFormat(); $content_type_format = $request->getContentType(); diff --git a/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php b/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php index b10fbfe..5cf2953 100644 --- a/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php +++ b/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php @@ -92,7 +92,7 @@ public function testResponseFormat($methods, array $supported_formats, $request_ if ($request_format) { $request->setRequestFormat($request_format); } - $route_requirement_key_format = $request->isMethodCacheable() ? '_format' : '_content_type_format'; + $route_requirement_key_format = $request->isMethodSafe() ? '_format' : '_content_type_format'; $route_match = new RouteMatch('test', new Route('/rest/test', ['_rest_resource_config' => $this->randomMachineName()], [$route_requirement_key_format => implode('|', $supported_formats)])); $resource_response_subscriber = new ResourceResponseSubscriber( @@ -129,7 +129,7 @@ public function testOnResponseWithCacheableResponse($methods, array $supported_f if ($request_format) { $request->setRequestFormat($request_format); } - $route_requirement_key_format = $request->isMethodCacheable() ? '_format' : '_content_type_format'; + $route_requirement_key_format = $request->isMethodSafe() ? '_format' : '_content_type_format'; $route_match = new RouteMatch('test', new Route('/rest/test', ['_rest_resource_config' => $rest_config_name], [$route_requirement_key_format => implode('|', $supported_formats)])); // The RequestHandler must return a ResourceResponseInterface object. @@ -179,7 +179,7 @@ public function testOnResponseWithUncacheableResponse($methods, array $supported if ($request_format) { $request->setRequestFormat($request_format); } - $route_requirement_key_format = $request->isMethodCacheable() ? '_format' : '_content_type_format'; + $route_requirement_key_format = $request->isMethodSafe() ? '_format' : '_content_type_format'; $route_match = new RouteMatch('test', new Route('/rest/test', ['_rest_resource_config' => $rest_config_name], [$route_requirement_key_format => implode('|', $supported_formats)])); // The RequestHandler must return a ResourceResponseInterface object. diff --git a/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php b/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUncacheableMethodTest.php similarity index 88% rename from core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php rename to core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUncacheableMethodTest.php index 2f62f1e..6b138eb 100644 --- a/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php +++ b/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUncacheableMethodTest.php @@ -7,22 +7,22 @@ use Symfony\Component\HttpFoundation\Request; /** - * @coversDefaultClass \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod + * @coversDefaultClass \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUncacheableMethod * @group PageCache */ -class CommandLineOrUnsafeMethodTest extends UnitTestCase { +class CommandLineOrUncacheableMethodTest extends UnitTestCase { /** * The request policy under test. * - * @var \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUncacheableMethod|\PHPUnit_Framework_MockObject_MockObject */ protected $policy; protected function setUp() { // Note that it is necessary to partially mock the class under test in // order to disable the isCli-check. - $this->policy = $this->getMock('Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod', array('isCli')); + $this->policy = $this->getMock('Drupal\Core\PageCache\RequestPolicy\CommandLineOrUncacheableMethod', array('isCli')); } /**