Search code examples
phpsymfony-3.1

Error "Property controller does not exist" when rendering @WebProfiler/Collector/request.html.twig


Just started seeing this. The debug tool bar fails to load. The error in the log file is:

[2016-07-29 08:49:48] request.CRITICAL: Uncaught PHP Exception Twig_Error_Runtime: "Neither the property "controller" nor one of the methods "controller()", "getcontroller()"/"iscontroller()" or "__call()" exist and have public access in class "SiteBundle\Library\Session" in "@WebProfiler/Collector/request.html.twig" at line 12" at /Volumes/Data01/VMShares/BeckComputerSystems/WarehouseWebUserInterface/WWUI/var/cache/dev/classes.php line 5481

The thing that really baffles me is the reference to my custom Session class. I have absolutely no idea why the request data collector would expect the Session object to have access to the controller.

If I put a break point in the serialize() method of Symfony\Component\HttpKernel\DataCollector I can see that $this->data->redirect is an object of my custom Session class. Again, no idea why.

This happens only on redirects and only for the toolbar. The page itself loads fine.

Help would be appreciated.


Solution

  • Turns out this is my bad -- big surprise :-)

    My custom Session class adds a fluent interface to the base Session class.

    When I implemented the remove() method I failed to notice that the base class returns the value that was removed. My implementation discarded it and returned the Session. This resulted in the RequestDataCollector::collect() method to store my session object instead of the value of sf_redirect.