merged branch fabriceb/master (PR #9060)

This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #9060).

Discussion
----------

[HttpKernel] fixes RequestDataCollector bug, visible on Drupal8

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

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 ===

Commits
-------

ba85279 [HttpKernel] fixes RequestDataCollector bug, visible when used on Drupal8
This commit is contained in:
Fabien Potencier 2013-09-17 21:54:49 +02:00
commit 5ffe1bc0e0
1 changed files with 2 additions and 2 deletions

View File

@ -50,9 +50,9 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
$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);
}