bug #29113 [Routing] fix dumping conditions that use the request (nicolas-grekas)
This PR was merged into the 4.2-dev branch.
Discussion
----------
[Routing] fix dumping conditions that use the request
| Q | A
| ------------- | ---
| Branch? | 4.2
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #29106
| License | MIT
| Doc PR | -
Commits
-------
09d5be8dac
[Routing] fix dumping conditions that use the request
This commit is contained in:
commit
626a61093e
@ -400,7 +400,7 @@ EOF;
|
|||||||
|
|
||||||
if ($condition = $route->getCondition()) {
|
if ($condition = $route->getCondition()) {
|
||||||
$condition = $this->getExpressionLanguage()->compile($condition, array('context', 'request'));
|
$condition = $this->getExpressionLanguage()->compile($condition, array('context', 'request'));
|
||||||
$condition = $conditions[$condition] ?? $conditions[$condition] = ((false !== strpos($condition, '$request')) - 1) * \count($conditions);
|
$condition = $conditions[$condition] ?? $conditions[$condition] = (false !== strpos($condition, '$request') ? 1 : -1) * \count($conditions);
|
||||||
} else {
|
} else {
|
||||||
$condition = 'null';
|
$condition = 'null';
|
||||||
}
|
}
|
||||||
|
@ -455,6 +455,9 @@ class UrlMatcherTest extends TestCase
|
|||||||
{
|
{
|
||||||
$coll = new RouteCollection();
|
$coll = new RouteCollection();
|
||||||
$route = new Route('/foo/{bar}');
|
$route = new Route('/foo/{bar}');
|
||||||
|
$route->setCondition('request.getBaseUrl() == "/bar"');
|
||||||
|
$coll->add('bar', $route);
|
||||||
|
$route = new Route('/foo/{bar}');
|
||||||
$route->setCondition('request.getBaseUrl() == "/sub/front.php" and request.getPathInfo() == "/foo/bar"');
|
$route->setCondition('request.getBaseUrl() == "/sub/front.php" and request.getPathInfo() == "/foo/bar"');
|
||||||
$coll->add('foo', $route);
|
$coll->add('foo', $route);
|
||||||
$matcher = $this->getUrlMatcher($coll, new RequestContext('/sub/front.php'));
|
$matcher = $this->getUrlMatcher($coll, new RequestContext('/sub/front.php'));
|
||||||
|
Reference in New Issue
Block a user