-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing][WIP] Support routes parameters names that are longer than 32 characters #20327
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
…racters WIP - Tests are missing fix routes dump
Instead of trying to make it work, I suggest trying to make it fail properly. This never worked, so we're not going to break anything. |
Agree with @nicolas-grekas |
@fancyweb Can you work on a fix based on @nicolas-grekas suggestion? |
Ok I will make a new PR. I was waiting for more opinions on this. What do you think of simply throwing an Exception in the |
… be used as a PCRE subpattern name (fancyweb) This PR was squashed before being merged into the 2.7 branch (closes #20474). Discussion ---------- [Routing] Fail properly when a route parameter name cannot be used as a PCRE subpattern name | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | symfony/symfony-docs#7139 This is a follow up PR to #20327. I also decided to improve the current `is_numeric()` check that is done by a truer one. The current limitation is that a PCRE subpattern name must not start with a digit which is different. Commits ------- 73fbd08 [Routing] Fail properly when a route parameter name cannot be used as a PCRE subpattern name
… be used as a PCRE subpattern name (fancyweb) This PR was squashed before being merged into the 2.7 branch (closes #20474). Discussion ---------- [Routing] Fail properly when a route parameter name cannot be used as a PCRE subpattern name | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | symfony/symfony-docs#7139 This is a follow up PR to symfony/symfony#20327. I also decided to improve the current `is_numeric()` check that is done by a truer one. The current limitation is that a PCRE subpattern name must not start with a digit which is different. Commits ------- 73fbd08 [Routing] Fail properly when a route parameter name cannot be used as a PCRE subpattern name
This seems like a really weak argument to me. Because it never worked, lets not improve anything? There are legitimate reasons to want more than 32 characters, such as prefixes in large code-bases, following conventions etc. Increasing the limit brings nothing but advantages. A quick google search will bring up quite a few results, meaning this is an actual issue that people are facing. Thanks for your improvement fancyweb, I will use your solution in the meantime. |
@ryan-senn If you can provide a good example (actual route paths) it maybe possible this can be reconsidered. Looking at the generated result it doesn't seem to affect code or performance under normal conditions (names <32 chars). But I would vote for a better naming system as |
@sstok I actually found this problem with real route paths that are very long because of my own convention that consist of using the full entity name as the placeholder name in my route. For instance, in one big project I have the entity Currently, this project has 619 routes and I would like all of them to follow the same convention for clarity and clean / logic code, but with the 32 characters limit, the convention cannot be respected : it breaks the project logic. I know that my convention is not THE convention, but as @ryan-senn said, supporting more than 32 characters will only bring advantages. |
That seems like a valid use-case, but I'm not able to vote 😜 If performance for the "old" situation is not affected I think it's reasonable to accept this. |
Currently, if in one of your route you have a parameter name that exceeds a length of 32 characters, the compilation of the regex fail in the generated
UrlMatcher
because the subpattern name used for the route parameter is too long (cf #8933).There is not a single warning about this before you actually try to reach the generated url and you end up with a 500 error.
I fixed this problem by using an alias system that replaces parameters names that are too long by aliases when the route is compiled, and then that replace those aliases by their real names once the request url has been matched with a route.
I need feedback on my idea as this is my first contribution :
CompiledRoute
class (https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Routing/Tests/RouteTest.php#L227) : what can I do about this ?UrlMatcher