This PR was submitted for the 2.8 branch but it was merged into the 2.3 branch instead (closes #16386).
Discussion
----------
Bug #16343 [Router] Too many Routes ?
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | https://github.com/symfony/symfony/issues/16343
| License | MIT
| Doc PR | N/A
Seems there is an issue when you have more than 7265 routes declared,
The routes are generated into the cached appDevUrlGenerator.php but php only loads the last 7265 elements of the array.
Commits
-------
0113ac3
Bug #16343 [Router] Too many Routes ?
This commit is contained in:
commit
bece73aa27
@ -53,7 +53,7 @@ use Psr\Log\LoggerInterface;
|
||||
*/
|
||||
class {$options['class']} extends {$options['base_class']}
|
||||
{
|
||||
private static \$declaredRoutes = {$this->generateDeclaredRoutes()};
|
||||
private static \$declaredRoutes;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -62,6 +62,9 @@ class {$options['class']} extends {$options['base_class']}
|
||||
{
|
||||
\$this->context = \$context;
|
||||
\$this->logger = \$logger;
|
||||
if (null === self::\$declaredRoutes) {
|
||||
self::\$declaredRoutes = {$this->generateDeclaredRoutes()};
|
||||
}
|
||||
}
|
||||
|
||||
{$this->generateGenerateMethod()}
|
||||
|
@ -34,6 +34,11 @@ class PhpGeneratorDumperTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
private $testTmpFilepath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $largeTestTmpFilepath;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
@ -41,7 +46,9 @@ class PhpGeneratorDumperTest extends \PHPUnit_Framework_TestCase
|
||||
$this->routeCollection = new RouteCollection();
|
||||
$this->generatorDumper = new PhpGeneratorDumper($this->routeCollection);
|
||||
$this->testTmpFilepath = sys_get_temp_dir().DIRECTORY_SEPARATOR.'php_generator.'.$this->getName().'.php';
|
||||
$this->largeTestTmpFilepath = sys_get_temp_dir().DIRECTORY_SEPARATOR.'php_generator.'.$this->getName().'.large.php';
|
||||
@unlink($this->testTmpFilepath);
|
||||
@unlink($this->largeTestTmpFilepath);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
@ -76,6 +83,33 @@ class PhpGeneratorDumperTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($relativeUrlWithoutParameter, '/app.php/testing2');
|
||||
}
|
||||
|
||||
public function testDumpWithTooManyRoutes()
|
||||
{
|
||||
$this->routeCollection->add('Test', new Route('/testing/{foo}'));
|
||||
for ( $i = 0; $i < 32769; ++$i ) {
|
||||
$this->routeCollection->add('route_'.$i, new Route('/route_'.$i));
|
||||
}
|
||||
$this->routeCollection->add('Test2', new Route('/testing2'));
|
||||
|
||||
$data = $this->generatorDumper->dump(array(
|
||||
'class' => 'ProjectLargeUrlGenerator',
|
||||
));
|
||||
file_put_contents($this->largeTestTmpFilepath, $data);
|
||||
include $this->largeTestTmpFilepath;
|
||||
|
||||
$projectUrlGenerator = new \ProjectLargeUrlGenerator(new RequestContext('/app.php'));
|
||||
|
||||
$absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals($absoluteUrlWithParameter, 'http://localhost/app.php/testing/bar');
|
||||
$this->assertEquals($absoluteUrlWithoutParameter, 'http://localhost/app.php/testing2');
|
||||
$this->assertEquals($relativeUrlWithParameter, '/app.php/testing/bar');
|
||||
$this->assertEquals($relativeUrlWithoutParameter, '/app.php/testing2');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
|
Reference in New Issue
Block a user