Description
How to reproduce
- Create a controller action that contains
$foo->bar();
. Make sure that$foo
is undefined. - Call said controller in both the
prod
anddev
environments.
Code sample
<?php
// src/Acme/BugReportBundle/Controller/BuggyController.php
namespace Acme\BugReportBundle\Controller;
class BuggyController
{
public function indexAction()
{
$foo->bar();
}
}
Attempt at analysis
When indexAction()
is called, Symfony will display a blank page if Debug::enable()
was called before (for example, if the dev
environment is being used).
If you insert $foo = null;
before $foo->bar();
, then Symfony's fatal error page will be displayed as intended.
Debug::enable()
registers \Symfony\Component\Debug\ErrorHandler
as an error handler. $foo->bar()
will make PHP display two errors:
- Notice: Undefined variable: foo in file on line line
- Fatal error: Call to a member function bar() on a non-object in file on line line
The notice will trigger ErrorHandler::handle()
, which will in turn raise a \Symfony\Component\Debug\Exception\ContextErrorException
. However, presumably because of the fatal error in the same line, Symfony's "Exception detected" page will not be displayed. The thrown ContextErrorException
also prevents ErrorHandler::handleFatal()
from being called (if the line that throws said exception is commented out, handleFatal()
will be called and the error page is displayed properly). Because of this, a blank page will be displayed which is not really useful for debugging.
Other information
Operating system: Debian GNU/Linux 6.0.7 (Linux 2.6.32 i686)
Symfony version: 2.3.3
PHP version: 5.3.6-11 (running via FastCGI)