<p dir="auto">The php error :<br>
PHP Fatal error:  Call to a member function getRepository() on a non-object</p>
<p dir="auto">is suppressed and a blank page is rendered despite being in dev ( app_dev.php )</p>
<p dir="auto">To replicate:<br>
remove $em = $this-&gt;getDoctrine()-&gt;getManager(); from any crud action.</p>
<h3 dir="auto">How to reproduce</h3>
<ol dir="auto">
<li>Create a controller action that contains <code class="notranslate">$foo-&gt;bar();</code>. Make sure that <code class="notranslate">$foo</code> is undefined.</li>
<li>Call said controller in both the <code class="notranslate">prod</code> and <code class="notranslate">dev</code> environments.</li>
</ol>
<h3 dir="auto">Code sample</h3>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?php

// src/Acme/BugReportBundle/Controller/BuggyController.php
namespace Acme\BugReportBundle\Controller;

class BuggyController
{
    public function indexAction()
    {
        $foo-&gt;bar();
    }
}"><pre class="notranslate"><span class="pl-ent">&lt;?php</span>

<span class="pl-c">// src/Acme/BugReportBundle/Controller/BuggyController.php</span>
<span class="pl-k">namespace</span> <span class="pl-v">Acme</span>\<span class="pl-v">BugReportBundle</span>\<span class="pl-v">Controller</span>;

<span class="pl-k">class</span> <span class="pl-v">BuggyController</span>
{
    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">indexAction</span>()
    {
        <span class="pl-s1"><span class="pl-c1">$</span>foo</span>-&gt;<span class="pl-en">bar</span>();
    }
}</pre></div>
<h3 dir="auto">Attempt at analysis</h3>
<p dir="auto">When <code class="notranslate">indexAction()</code> is called, Symfony will display a blank page if <code class="notranslate">Debug::enable()</code> was called before (for example, if the <code class="notranslate">dev</code> environment is being used).</p>
<p dir="auto">If you insert <code class="notranslate">$foo = null;</code> before <code class="notranslate">$foo-&gt;bar();</code>, then Symfony's fatal error page will be displayed as intended.</p>
<p dir="auto"><code class="notranslate">Debug::enable()</code> registers <code class="notranslate">\Symfony\Component\Debug\ErrorHandler</code> as an error handler. <code class="notranslate">$foo-&gt;bar()</code> will make PHP display two errors:</p>
<ol dir="auto">
<li>Notice: Undefined variable: foo in <em>file</em> on line <em>line</em></li>
<li>Fatal error: Call to a member function bar() on a non-object in <em>file</em> on line <em>line</em></li>
</ol>
<p dir="auto">The notice will trigger <code class="notranslate">ErrorHandler::handle()</code>, which will in turn raise a <code class="notranslate">\Symfony\Component\Debug\Exception\ContextErrorException</code>. However, presumably because of the fatal error in the same line, Symfony's "Exception detected" page will not be displayed. The thrown <code class="notranslate">ContextErrorException</code> also prevents <code class="notranslate">ErrorHandler::handleFatal()</code> from being called (if the line that throws said exception is commented out, <code class="notranslate">handleFatal()</code> 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.</p>
<h3 dir="auto">Other information</h3>
<p dir="auto"><strong>Operating system:</strong> Debian GNU/Linux 6.0.7 (Linux 2.6.32 i686)<br>
<strong>Symfony version:</strong> 2.3.3<br>
<strong>PHP version:</strong> 5.3.6-11 (running via FastCGI)</p>