[FrameworkBundle] removed the possibility to pass a non-scalar attributes when calling render() to make the call works with or without a reverse proxy (closes #2941)
This commit is contained in:
parent
1e2d1a3406
commit
254e49b47c
@ -26,6 +26,7 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
|
||||
|
||||
### FrameworkBundle
|
||||
|
||||
* [BC BREAK] removed the possibility to pass a non-scalar attributes when calling render() to make the call works with or without a reverse proxy
|
||||
* added a router:match command
|
||||
* added kernel.event_subscriber tag
|
||||
* added a way to create relative symlinks when running assets:install command (--relative option)
|
||||
|
@ -105,6 +105,14 @@ class HttpKernel extends BaseHttpKernel
|
||||
'comment' => '',
|
||||
), $options);
|
||||
|
||||
// enforce all attribute values to be scalars to be sure that the same
|
||||
// render() call will work with or without a reverse proxy
|
||||
foreach ($options['attributes'] as $key => $value) {
|
||||
if (!is_scalar($value)) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to render the "%s" controller as the "%s" attribute is not a scalar.', $controller, $key));
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($options['alt'])) {
|
||||
$options['alt'] = array($options['alt']);
|
||||
}
|
||||
|
@ -219,4 +219,17 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals('Foo', ob_get_clean());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testRenderOnlyAllowScalarAttributes()
|
||||
{
|
||||
$dispatcher = new EventDispatcher();
|
||||
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$kernel = new HttpKernel($dispatcher, $container, $resolver);
|
||||
|
||||
$kernel->render('/', array('attributes' => array('foo' => new \stdClass())));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user