The rest module is doing things with routes. And route manager page manager is also doing things with routes...
To reproduce:

  1. Install page_manager
  2. Install rest

Vist: admin/structure/page_manager

The website encountered an unexpected error. Please try again later.

Symfony\Component\Routing\Exception\MethodNotAllowedException: in Symfony\Component\Routing\Matcher\UrlMatcher->match() (line 97 of vendor/symfony/routing/Matcher/UrlMatcher.php).

Drupal\Core\Routing\UrlMatcher->finalMatch(Object, Object)
Symfony\Cmf\Component\Routing\NestedMatcher\NestedMatcher->matchRequest(Object)
Symfony\Cmf\Component\Routing\DynamicRouter->matchRequest(Object)
Symfony\Cmf\Component\Routing\ChainRouter->doMatch('/node/{node}')
Symfony\Cmf\Component\Routing\ChainRouter->match('/node/{node}')
Drupal\Core\Path\PathValidator->getPathAttributes('node/{node}', Object, )
Drupal\Core\Path\PathValidator->getUrl('node/{node}', )
Drupal\Core\Path\PathValidator->getUrlIfValidWithoutAccessCheck('node/{node}')
Drupal\Core\Url::fromInternalUri(Array, Array)
Drupal\Core\Url::fromUri('internal:/node/{node}', Array)
Drupal\Core\Url::fromUserInput('/node/{node}')
Drupal\page_manager\Entity\PageListBuilder->getPath(Object)
Drupal\page_manager\Entity\PageListBuilder->buildRow(Object)
Drupal\Core\Entity\EntityListBuilder->render()
Drupal\page_manager\Entity\PageListBuilder->render()
Drupal\Core\Entity\Controller\EntityListController->listing('page')
call_user_func_array(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

brantwynn created an issue. See original summary.

tim.plunkett’s picture

Title: page_manager admin page error when rest module enabled » \Drupal\Core\Path\PathValidator::getPathAttributes() does not catch MethodNotAllowedException
Project: Page Manager » Drupal core
Version: 8.x-1.x-dev » 8.0.x-dev
Component: Code » path.module
Priority: Normal » Major
Status: Active » Needs review
Issue tags: +Contributed project blocker
FileSize
5.3 KB
6.16 KB

This is actually a core bug. \Drupal\Core\Path\PathValidator::getPathAttributes() is not documented as throwing any exceptions, so it should be safe to call.
However, it only catches 3 of the 4 exceptions that are possible.

The last submitted patch, 2: 2619700-pathvalidator-2-FAIL.patch, failed testing.

tim.plunkett’s picture

+++ b/core/lib/Drupal/Core/Path/PathValidator.php
@@ -16,6 +16,7 @@
+use Symfony\Component\Routing\Exception\MethodNotAllowedException;

@@ -170,6 +171,9 @@ protected function getPathAttributes($path, Request $request, $access_check) {
+    catch (MethodNotAllowedException $e) {
+      return FALSE;
+    }

+++ b/core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php
@@ -13,6 +13,7 @@
+use Symfony\Component\Routing\Exception\MethodNotAllowedException;

@@ -209,6 +214,72 @@ public function testIsValidWithAccessDenied() {
+  /**
+   * @covers ::isValid
+   * @covers ::getPathAttributes
+   */
+  public function testIsValidWithMethodNotAllowed() {
+    $this->account->expects($this->once())
+      ->method('hasPermission')
+      ->with('link to any page')
+      ->willReturn(FALSE);
+    $this->accessUnawareRouter->expects($this->never())
+      ->method('match');
+    $this->accessAwareRouter->expects($this->once())
+      ->method('match')
+      ->with('/test-path')
+      ->willThrowException(new MethodNotAllowedException([]));
+    $this->pathProcessor->expects($this->once())
+      ->method('processInbound')
+      ->willReturnArgument(0);
+
+    $this->assertFalse($this->pathValidator->isValid('test-path'));
+  }

These are the only lines absolutely needed. The rest of the test changes I did to figure out where coverage was coming from, and could be committed separately, or left here as-is.

jibran’s picture

Status: Needs review » Reviewed & tested by the community

I think this is fine as is.

The last submitted patch, 2: 2619700-pathvalidator-2-FAIL.patch, failed testing.

  • catch committed 438713d on 8.0.x
    Issue #2619700 by tim.plunkett: \Drupal\Core\Path\PathValidator::...

  • catch committed c551eff on 8.1.x
    Issue #2619700 by tim.plunkett: \Drupal\Core\Path\PathValidator::...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.1.x and cherry-picked to 8.0.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.