bug #23121 [Routing] Revert the change in [#b42018] with respect to Routing/Route.php (Dan Wilga)
This PR was submitted for the master branch but it was merged into the 3.3 branch instead (closes #23121).
Discussion
----------
[Routing] Revert the change in [#b42018] with respect to Routing/Route.php
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #21090 #23109
| License | MIT
| Doc PR |
...because it breaks BC with third-party code which, for instance, might use a subclass of CompiledRoute within the options portion of the Route. Refers to https://github.com/symfony/symfony/pull/21090 and https://github.com/symfony/symfony/issues/23109
Commits
-------
f09893bed4
[Routing] Revert the change in [#b42018] with respect to Routing/Route.php
This commit is contained in:
commit
9649b9e5ca
@ -116,11 +116,7 @@ class Route implements \Serializable
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70000) {
|
||||
$data = unserialize($serialized, array('allowed_classes' => array(CompiledRoute::class)));
|
||||
} else {
|
||||
$data = unserialize($serialized);
|
||||
}
|
||||
$data = unserialize($serialized);
|
||||
$this->path = $data['path'];
|
||||
$this->host = $data['host'];
|
||||
$this->defaults = $data['defaults'];
|
||||
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Routing\CompiledRoute;
|
||||
|
||||
class CustomCompiledRoute extends CompiledRoute
|
||||
{
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCompiler;
|
||||
|
||||
class CustomRouteCompiler extends RouteCompiler
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function compile(Route $route)
|
||||
{
|
||||
return new CustomCompiledRoute('', '', array(), array());
|
||||
}
|
||||
}
|
@ -220,6 +220,24 @@ class RouteTest extends TestCase
|
||||
$this->assertNotSame($route, $unserialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that unserialization does not fail when the compiled Route is of a
|
||||
* class other than CompiledRoute, such as a subclass of it.
|
||||
*/
|
||||
public function testSerializeWhenCompiledWithClass()
|
||||
{
|
||||
$route = new Route('/', array(), array(), array('compiler_class' => '\Symfony\Component\Routing\Tests\Fixtures\CustomRouteCompiler'));
|
||||
$this->assertInstanceOf('\Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute', $route->compile(), '->compile() returned a proper route');
|
||||
|
||||
$serialized = serialize($route);
|
||||
try {
|
||||
$unserialized = unserialize($serialized);
|
||||
$this->assertInstanceOf('\Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute', $unserialized->compile(), 'the unserialized route compiled successfully');
|
||||
} catch (\Exception $e) {
|
||||
$this->fail('unserializing a route which uses a custom compiled route class');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the serialized representation of a route in one symfony version
|
||||
* also works in later symfony versions, i.e. the unserialized route is in the
|
||||
|
Reference in New Issue
Block a user