Skip to content
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

[Routing] make xml loader more tolerant #7268

Merged
merged 2 commits into from
Mar 6, 2013

Conversation

Tobion
Copy link
Contributor

@Tobion Tobion commented Mar 5, 2013

schemes and methods may also be delimited by whitespace, comma or pipe.
Fixes #6049 (comment)
this eases migration as now methods="GET|POST" also works
the second commit unifies the tests and fixes some strange assertions that were useless

Q A
Bug fix? [yes]
New feature? [yes but not really]
BC breaks? [no]
Deprecations? [no]
Tests pass? [yes]
License MIT

schemes and methods may also be delimited by whitespace, comma or pipe.
this eases migration as now schemes="GET|POST" also works
$schemes = array_filter(explode(' ', $node->getAttribute('schemes')));
$methods = array_filter(explode(' ', $node->getAttribute('methods')));
$schemes = preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY);
$methods = preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 2 + ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It prevents backtracking. So its a performance thing (which I also implemented for UrlMatching/route compiling some time ago).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say it's a micro-optim which:

  • makes the code unclear,
  • is really useless as you want to use the compiled version where perf matters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well its standard syntax for regular expressions. Just less known.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw where could there be any backtracking here ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(but thanks for the tip++ anyway!)

fabpot added a commit that referenced this pull request Mar 6, 2013
This PR was merged into the 2.2 branch.

Commits
-------

54c333d [Routing] unify and fix the loader tests
41ad9d8 [Routing] make xml loader more tolerant

Discussion
----------

[Routing] make xml loader more tolerant

schemes and methods may also be delimited by whitespace, comma or pipe.
Fixes #6049 (comment)
this eases migration as now `methods="GET|POST"` also works
the second commit unifies the tests and fixes some strange assertions that were useless

| Q             | A
| ------------- | ---
| Bug fix?      | [yes]
| New feature?  | [yes but not really]
| BC breaks?    | [no]
| Deprecations? | [no]
| Tests pass?   | [yes]
| License       | MIT
@fabpot fabpot merged commit 54c333d into symfony:2.2 Mar 6, 2013
@Tobion Tobion deleted the scheme-method-def-tolerance branch March 6, 2013 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants