Skip to content

Commit

Permalink
fixes RequestDataCollector bug, visible when used on Drupal8
Browse files Browse the repository at this point in the history
In Drupal8 ```$request->attributes->all()``` returns an array with a 0 key whose value is the ```Drupal\user\Entity\User```

```php
array(
 0 => Drupal\user\Entity\User,
 ...
)
```

```('_route' == $key && is_object($value))``` is therefore true which provokes an exception:

```php
FatalErrorException: Error: Call to undefined method Drupal\user\Entity\User::getPath() in [...]/RequestDataCollector.php line 54
```

This patch corrects this with a simple replacement of == by ===
  • Loading branch information
Fabrice Bernhard authored and fabpot committed Sep 17, 2013
1 parent 6f5de63 commit 0e80d88
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public function collect(Request $request, Response $response, \Exception $except

$attributes = array();
foreach ($request->attributes->all() as $key => $value) {
if ('_route' == $key && is_object($value)) {
if ('_route' === $key && is_object($value)) {
$attributes['_route'] = $this->varToString($value->getPath());
} elseif ('_route_params' == $key) {
} elseif ('_route_params' === $key) {
foreach ($value as $key => $v) {
$attributes['_route_params'][$key] = $this->varToString($v);
}
Expand Down

0 comments on commit 0e80d88

Please sign in to comment.