diff --git a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php index f5bf1f4..22e82d2 100644 --- a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php @@ -43,9 +43,13 @@ public function onRouteBuilding(RouteBuildEvent $event) { foreach ($event->getRouteCollection()->all() as $route) { if ($not_allowed_variables = array_intersect($route->compile()->getVariables(), $special_variables)) { - throw new \InvalidArgumentException(String::format('The following variables are reserved names by drupal: @variables', array('@variables' => implode(', ', $not_allowed_variables)))); + $placeholders = array('@variables' => implode(', ', $not_allowed_variables)); + drupal_set_message(String::format('The following variables are reserved names by drupal: @variables', $placeholders)); + watchdog('error', 'The following variables are reserved names by drupal: @variables', $placeholders); + return FALSE; } } + return TRUE; } /** diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php index f5f8f25..7555768 100644 --- a/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php +++ b/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php @@ -5,7 +5,7 @@ * Contains \Drupal\Tests\Core\EventSubscriber\SpecialAttributesRouteSubscriberTest. */ -namespace Drupal\Tests\Core\EventSubscriber; +namespace Drupal\Tests\Core\EventSubscriber { use Drupal\Core\EventSubscriber\SpecialAttributesRouteSubscriber; use Drupal\Core\Routing\RouteBuildEvent; @@ -95,7 +95,7 @@ public function testOnRouteBuildingValidVariables(Route $route) { $route_collection = new RouteCollection(); $route_collection->add('test', $route); $event = new RouteBuildEvent($route_collection, 'test'); - $this->specialAttributesRouteSubscriber->onRouteBuilding($event); + $this->assertTrue($this->specialAttributesRouteSubscriber->onRouteBuilding($event)); } /** @@ -105,14 +105,25 @@ public function testOnRouteBuildingValidVariables(Route $route) { * The route to check. * * @dataProvider providerTestOnRouteBuildingInvalidVariables - * - * @expectedException \InvalidArgumentException */ public function testOnRouteBuildingInvalidVariables(Route $route) { $route_collection = new RouteCollection(); $route_collection->add('test', $route); $event = new RouteBuildEvent($route_collection, 'test'); - $this->specialAttributesRouteSubscriber->onRouteBuilding($event); + $this->assertFalse($this->specialAttributesRouteSubscriber->onRouteBuilding($event)); } } + +} + +namespace { + if (!function_exists('watchdog')) { + function watchdog($type, $message, array $args = NULL) { + } + } + if (!function_exists('drupal_set_message')) { + function drupal_set_message($type = NULL, $message = '') { + } + } +}