-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Bug #16343 [Router] Too many Routes ? #16386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
AFAIK php arrays are only limited my memory. So what does this solve? |
358aa72
to
98314f2
Compare
I know, that's what I thought as well. yet when I checked out https://github.com/AntoineLemaire/symfony-standard/commits/2.8, and I debugged the generated appDevUrlGenerator.php file by dumping the well after a bit of experimenting it seems the issue is that declaring the routes in the constructor instead of the class fixes it as well. will make a test case to illustrate the issue. |
you can find an illustration of the issue at http://khepri.be/test_appDevUrlGenerator.php ( source at http://khepri.be/test_appDevUrlGenerator.php.txt ) Basicly 2 identical arrays, one defined in the class and one in the constructor. |
f744e8d
to
032d386
Compare
|
Seems to be an issue from php 5.6+ you can find a simplified example at https://gist.github.com/jelte/b2a9d73aec0211b07f6e |
Then I suggest reporting this. As it probably also doesn't work in 7.0 |
I confirm the bug in PHP 5.6.13. Seems pretty serious. Can somebody report it on PHP? |
It was marked duplicate, and can't be fixed without breaking extensions. Not using static may work also, but is a problem when you use something like ReactPHP and get allot of duplicated values in memory. If you have this many routes, I guess one way to make it work is to separate them using a (I hope get this term right) binary-tree when the routes are split over multiple static variables (like done for the dumped matching). |
Known PHP issue for PHP5.6+ but it is only fixed in PHP7+. [2015-03-23 17:51 UTC] [email protected] |
65bf924
to
8cb24cc
Compare
As this is a bug in PHP 5.6 which won't be fixed I made it an exception for that specific PHP version and only in case you have a large number of routes. @sstok The large number of routes are due to a large amount of locales (30+) and translated uri's (check the ticket), With large sites, without some dynamic routes it can happen. |
this needs to be covered by a test |
$routes = $this->generateDeclaredRoutes(); | ||
|
||
// Fix for https://bugs.php.net/bug.php?id=68057 - Bug #68057 Incorrect parsing of big arrays in PHP 5.6.0 | ||
if (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50700 && count($routes) > 32750) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 32750 ? Where did you get this value from ?
Also, please keep in mind that, if the size of the array is very large (maybe 50K), then count
will also not work correctly. I just tested this on PHP 5.6 with an array of 56K elements. In that case, count
said the array contained 23K elements.
So checking this with count
won't work.... Unfortunately I can't think of an alternative implementation off-the-top of my head :( .
56ebc5b
to
058f5fa
Compare
@@ -38,6 +38,45 @@ public function dump(array $options = array()) | |||
'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', | |||
), $options); | |||
|
|||
$routes = $this->generateDeclaredRoutes(); | |||
|
|||
// Fix for https://bugs.php.net/bug.php?id=68057 - Bug #68057 Incorrect parsing of big arrays in PHP 5.6.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug is contained in 5.6.* not only 5.6.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50700
=> any version between 5.6 & 5.7, comment is the title of the bug report.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the impl. is fine, just the comment is not consistent with the code.
17991e0
to
0ee6033
Compare
@@ -62,6 +62,9 @@ public function __construct(RequestContext \$context, LoggerInterface \$logger = | |||
{ | |||
\$this->context = \$context; | |||
\$this->logger = \$logger; | |||
if ( null === self::\$declaredRoutes ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no space inside: if (null === self::\$declaredRoutes)
0ee6033
to
35dfe3e
Compare
👍 |
Thank you @jelte. |
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 | #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 ?
@nicolas-grekas for some reason this PR wasn't closed even though you merged it. |
@jakzal that's because it was rebased (on top of 2.3) while merging, so it's not a normal merge commit. In such cases, PRs are closed only when the commit makes it into the default branch (2.8) (because the commit messages includes |
@wouterj yeah, that's what I thought. Cheers! |
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.