Skip to content

Commit 530fa5d

Browse files
committed
[HttpKernel] Fix a regression in the RequestDataCollector
1 parent dcfccf6 commit 530fa5d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ protected function parseController($controller)
374374
);
375375
}
376376

377-
return (string) $controller ?: 'n/a';
377+
return is_string($controller) ? $controller : 'n/a';
378378
}
379379

380380
private function getCookieHeader($name, $value, $expires, $path, $domain, $secure, $httponly)

src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\HttpKernel\Tests\DataCollector;
1313

14+
use Symfony\Component\HttpFoundation\RedirectResponse;
1415
use Symfony\Component\HttpFoundation\Session\Session;
1516
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
1617
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
@@ -182,6 +183,20 @@ function () { return 'foo'; },
182183
);
183184
}
184185

186+
public function testItIgnoresInvalidCallables()
187+
{
188+
$request = $this->createRequest();
189+
$request->attributes->set('_controller', 'Foo::bar');
190+
$request->setSession(new Session(new MockArraySessionStorage()));
191+
$request->getSession()->start();
192+
$response = new RedirectResponse('/');
193+
194+
$c = new RequestDataCollector();
195+
$c->collect($request, $response);
196+
197+
$this->assertSame('n/a', $c->getController());
198+
}
199+
185200
protected function createRequest()
186201
{
187202
$request = Request::create('http://test.com/foo?bar=baz');

0 commit comments

Comments
 (0)