Skip to content

Commit 09d5be8

Browse files
[Routing] fix dumping conditions that use the request
1 parent 8d277ce commit 09d5be8

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ private function compileRoute(Route $route, string $name, $vars, array &$conditi
400400

401401
if ($condition = $route->getCondition()) {
402402
$condition = $this->getExpressionLanguage()->compile($condition, array('context', 'request'));
403-
$condition = $conditions[$condition] ?? $conditions[$condition] = ((false !== strpos($condition, '$request')) - 1) * \count($conditions);
403+
$condition = $conditions[$condition] ?? $conditions[$condition] = (false !== strpos($condition, '$request') ? 1 : -1) * \count($conditions);
404404
} else {
405405
$condition = 'null';
406406
}

src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ public function testRequestCondition()
455455
{
456456
$coll = new RouteCollection();
457457
$route = new Route('/foo/{bar}');
458+
$route->setCondition('request.getBaseUrl() == "/bar"');
459+
$coll->add('bar', $route);
460+
$route = new Route('/foo/{bar}');
458461
$route->setCondition('request.getBaseUrl() == "/sub/front.php" and request.getPathInfo() == "/foo/bar"');
459462
$coll->add('foo', $route);
460463
$matcher = $this->getUrlMatcher($coll, new RequestContext('/sub/front.php'));

0 commit comments

Comments
 (0)