Skip to content

URL matcher crashes when using request object in condition #22635

Closed
@B-Galati

Description

@B-Galati

Hello,

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.2.5

When trying to use the url matcher against a route that uses a condition it would crash if the condition is using the request object.

I pushed an example of the issue on this branch -> so that anyone can check. Going to /en/blog/ would produce the bug.

Here is an example of output using router:match command.

❯ bin/console router:match /en/blog/rss.xml -vv

                                             
  [RuntimeException]                         
  Unable to get a property on a non-object.  
                                             

Exception trace:
 () at /home/benoit/workspace/symfony_demo/vendor/symfony/symfony/src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php:83
 Symfony\Component\ExpressionLanguage\Node\GetAttrNode->evaluate() at /home/benoit/workspace/symfony_demo/vendor/symfony/symfony/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php:81
 Symfony\Component\ExpressionLanguage\ExpressionLanguage->evaluate() at /home/benoit/workspace/symfony_demo/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php:108
 Symfony\Component\Routing\Matcher\TraceableUrlMatcher->matchCollection() at /home/benoit/workspace/symfony_demo/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/UrlMatcher.php:92
 Symfony\Component\Routing\Matcher\UrlMatcher->match() at /home/benoit/workspace/symfony_demo/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php:37
 Symfony\Component\Routing\Matcher\TraceableUrlMatcher->getTraces() at /home/benoit/workspace/symfony_demo/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php:95
 Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand->execute() at /home/benoit/workspace/symfony_demo/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:265
 Symfony\Component\Console\Command\Command->run() at /home/benoit/workspace/symfony_demo/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:852
 Symfony\Component\Console\Application->doRunCommand() at /home/benoit/workspace/symfony_demo/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:189
 Symfony\Component\Console\Application->doRun() at /home/benoit/workspace/symfony_demo/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:80
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/benoit/workspace/symfony_demo/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:120
 Symfony\Component\Console\Application->run() at /home/benoit/workspace/symfony_demo/bin/console:29

To reproduce, add a condition like condition="request.isXmlHttpRequest()" on any route then try to call the url matcher on this route like $this->get('router')->match('<tested_route>').

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions