diff --git a/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php b/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php index 15f1b96..8021568 100644 --- a/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php +++ b/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php @@ -156,7 +156,8 @@ public function enhance(array $defaults, Request $request) { // variables in the route path pattern. $route = $defaults[RouteObjectInterface::ROUTE_OBJECT]; $variables = array_flip($route->compile()->getVariables()); - // Explicitly copy values to break references. + // Because foreach copies the values from the array it iterates even if they + // are references, use it to break references. $raw_variables = array(); foreach (array_intersect_key($defaults, $variables) as $key => $value) { $raw_variables[$key] = $value; diff --git a/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php b/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php index 942a3f2..71671a0 100644 --- a/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php +++ b/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php @@ -151,6 +151,7 @@ public function providerTestGetConverter() { * @see \Drupal\Core\ParamConverter\ParamConverterManager::enhance(). */ public function testEnhance() { + // Create a mock route using a mock parameter converter. $converter = $this->getMock('Drupal\Core\ParamConverter\ParamConverterInterface'); $this->manager->addConverter('test_convert'); @@ -181,8 +182,11 @@ public function testEnhance() { $defaults = $this->manager->enhance($defaults, $request); + // The value of 1 should be upcast to the User object for UID 1. $this->assertSame($entity, $defaults['id']); + // The parameter for the user ID should be stored in the raw variables. $this->assertTrue($defaults['_raw_variables']->has('id')); + // The raw non-upcasted value for the user should be the UID. $this->assertEquals(1, $defaults['_raw_variables']->get('id')); }