diff --git a/core/includes/menu.inc b/core/includes/menu.inc index ac5d2c0..622339e 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -6,6 +6,7 @@ */ use Drupal\Component\Utility\NestedArray; +use Drupal\Component\Utility\String; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Language\Language; use Drupal\Core\Template\Attribute; @@ -977,7 +978,7 @@ function menu_item_route_access(Route $route, $href, &$map) { return FALSE; } catch (ResourceNotFoundException $e) { - return FALSE; + throw new ResourceNotFoundException(String::format("The route for '@href' could not be found", array('@href' => $href))); } // Populate the map with any matching values from the request. diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/RouterPermissionTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/RouterPermissionTest.php index 57d98be..5541b9f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Routing/RouterPermissionTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/RouterPermissionTest.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\Routing; use Drupal\simpletest\WebTestBase; +use Symfony\Component\Routing\Exception\ResourceNotFoundException; /** * Basic tests for access permissions in routes. @@ -36,11 +37,17 @@ public function testPermissionAccess() { $path = 'router_test/test7'; $this->drupalGet($path); $this->assertResponse(403, "Access denied for a route where we don't have a permission"); - // An invalid path should return a FALSE. + // An invalid path should throw an exception. $map = array(); $route = \Drupal::service('router.route_provider')->getRouteByName('router_test_7'); - $access = menu_item_route_access($route, $path . 'invalid', $map); - $this->assertFalse($access, 'Access denied'); + try { + menu_item_route_access($route, $path . 'invalid', $map); + $exception = FALSE; + } + catch (ResourceNotFoundException $e) { + $exception = TRUE; + } + $this->assertTrue($exception, 'A ResourceNotFoundException was thrown while checking access for an invalid route.'); $this->drupalGet('router_test/test8'); $this->assertResponse(403, 'Access denied by default if no access specified');