当我将调试模式设置为Production ...并且代码中发生可恢复的错误时,CakePHP将在UI中输出错误详细信息。如何阻止显示?
... debug config setting:
Configure::write('debug', 0);
...导致错误的示例代码(在控制器操作中):
$myError = $something['NullExceptionGoes']['HERE'];
...这会导致将cake-debug块添加到视图中(就在开始的body标签下方):
将输出错误详细信息...我不希望用户看到此信息...我想阻止此块显示
<pre class="cake-debug">
<a onclick="document.getElementById('cakeErr1-trace').style.display = (document.getElementById('cakeErr1-trace').style.display == 'none' ? '' : 'none');" href="javascript:void(0);"><b>Notice</b> (8)</a>
: Undefined variable: something [<b>APP/controllers/home_controller.php</b>, line <b>12</b>]
<div style="display: none;" class="cake-stack-trace" id="cakeErr1-trace">
<a onclick="document.getElementById('cakeErr1-code').style.display = (document.getElementById('cakeErr1-code').style.display == 'none' ? '' : 'none')" href="javascript:void(0);">Code</a> | <a onclick="document.getElementById('cakeErr1-context').style.display = (document.getElementById('cakeErr1-context').style.display == 'none' ? '' : 'none')" href="javascript:void(0);">Context</a><div style="display: none;" class="cake-code-dump" id="cakeErr1-code"><pre><code><span style="color: rgb(0, 0, 0);"> $this->set('title_for_layout', $title_for_layout);</span></code>
<code><span style="color: rgb(0, 0, 0);"></span></code>
<span class="code-highlight"><code><span style="color: rgb(0, 0, 0);"> $myvar = $something['nullexceptiongoeshere']['hello'];</span></code></span></pre></div>
<pre style="display: none;" class="cake-context" id="cakeErr1-context">$title_for_layout = "page title"</pre>
<pre class="stack-trace">HomeController::index() - APP/controllers/home_controller.php, line 12
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 83</pre>
</div>
</pre>
答案 0 :(得分:0)
您可能在控制器方法中覆盖了调试输出。
验证:
Configure::write('debug', x);
也不在您的控制器中(其中x = 1或2)。