diff --git a/composer.lock b/composer.lock index 19ee07126a166bc6d0f7c1aafdaa85f3606200ce..f7ac0c0cf257bd25d537f92e46a138b2cd9d5a72 100644 --- a/composer.lock +++ b/composer.lock @@ -1140,36 +1140,38 @@ }, { "name": "symfony-cmf/routing", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/symfony-cmf/Routing.git", - "reference": "8e87981d72c6930a27585dcd3119f3199f6cb2a6" + "reference": "b93704ca098334f56e9b317932f21a4362e620db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/8e87981d72c6930a27585dcd3119f3199f6cb2a6", - "reference": "8e87981d72c6930a27585dcd3119f3199f6cb2a6", + "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/b93704ca098334f56e9b317932f21a4362e620db", + "reference": "b93704ca098334f56e9b317932f21a4362e620db", "shasum": "" }, "require": { - "php": ">=5.3.3", - "psr/log": "~1.0", - "symfony/http-kernel": "~2.2", - "symfony/routing": "~2.2" + "php": "^5.3.9|^7.0", + "psr/log": "1.*", + "symfony/http-kernel": "^2.2|3.*", + "symfony/routing": "^2.2|3.*" }, "require-dev": { - "symfony/config": "~2.2", - "symfony/dependency-injection": "~2.0@stable", - "symfony/event-dispatcher": "~2.1" + "friendsofsymfony/jsrouting-bundle": "^1.1", + "symfony-cmf/testing": "^1.3", + "symfony/config": "^2.2|3.*", + "symfony/dependency-injection": "^2.0.5|3.*", + "symfony/event-dispatcher": "^2.1|3.*" }, "suggest": { - "symfony/event-dispatcher": "DynamicRouter can optionally trigger an event at the start of matching. Minimal version ~2.1" + "symfony/event-dispatcher": "DynamicRouter can optionally trigger an event at the start of matching. Minimal version (~2.1)" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -1193,7 +1195,7 @@ "database", "routing" ], - "time": "2014-10-20 20:55:17" + "time": "2016-03-31 09:11:39" }, { "name": "symfony/class-loader", diff --git a/core/composer.json b/core/composer.json index 1266df391afaaca725736ca0c6adbce429325096..ddcd1ceeadbd3b918d985e8c6cfccba5b4df920c 100644 --- a/core/composer.json +++ b/core/composer.json @@ -22,7 +22,7 @@ "doctrine/common": "2.5.*", "doctrine/annotations": "1.2.*", "guzzlehttp/guzzle": "~6.1", - "symfony-cmf/routing": "1.3.*", + "symfony-cmf/routing": "~1.4", "easyrdf/easyrdf": "0.9.*", "zendframework/zend-feed": "~2.4", "stack/builder": "1.0.*", diff --git a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php index 0d876cc7f1c173e9ec999444d508a4646fc40405..38cb8950d00273dfb486d48342942c078d207760 100644 --- a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php @@ -133,6 +133,14 @@ protected function makeSubrequest(GetResponseForExceptionEvent $event, $url, $st // would execute a subrequest with the 404 route's URL, then it'd be // generated for *that* URL, not the *original* URL. $sub_request = clone $request; + + // The routing to the 404 page should be done as GET request because it is + // restricted to GET and POST requests only. Otherwise a DELETE request + // would for example trigger a method not allowed exception. + $request_context = clone ($this->accessUnawareRouter->getContext()); + $request_context->setMethod('GET'); + $this->accessUnawareRouter->setContext($request_context); + $sub_request->attributes->add($this->accessUnawareRouter->match($url)); // Add to query (GET) or request (POST) parameters: diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php index 5d3993d3bb60c0f6611d45031a1448086751ef9a..81e7cc6a102d82d29d5d1dbc97c78f86d779d2ea 100644 --- a/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php +++ b/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php @@ -14,6 +14,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\Routing\RequestContext; /** * @coversDefaultClass \Drupal\Core\EventSubscriber\CustomPageExceptionHtmlSubscriber @@ -127,6 +128,12 @@ protected function tearDown() { public function testHandleWithPostRequest() { $request = Request::create('/test', 'POST', array('name' => 'druplicon', 'pass' => '12345')); + $request_context = new RequestContext(); + $request_context->fromRequest($request); + $this->accessUnawareRouter->expects($this->any()) + ->method('getContext') + ->willReturn($request_context); + $this->kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { return new HtmlResponse($request->getMethod()); })); @@ -148,6 +155,12 @@ public function testHandleWithGetRequest() { $request = Request::create('/test', 'GET', array('name' => 'druplicon', 'pass' => '12345')); $request->attributes->set(AccessAwareRouterInterface::ACCESS_RESULT, AccessResult::forbidden()->addCacheTags(['druplicon'])); + $request_context = new RequestContext(); + $request_context->fromRequest($request); + $this->accessUnawareRouter->expects($this->any()) + ->method('getContext') + ->willReturn($request_context); + $this->kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { return new Response($request->getMethod() . ' ' . UrlHelper::buildQuery($request->query->all())); }));