为什么在CakePHP中将调试更改为0会破坏静态页面?
一切正常。没有错误。我将debug改为0,突然我的页面出现404个错误,在我的日志中,我注意到我在app controller中声明的、以前工作正常的变量现在又返回为未定义的变量 古怪。为什么将调试更改为0会导致这种行为 编辑:2012年4月18日 我翻了翻页面控制器。在$path=func\u get\u参数之后;当我投进一个dieprint_r$路径时。使用debug 1或debug 2,它会在我的主页上返回以下内容:为什么在CakePHP中将调试更改为0会破坏静态页面?,cakephp,Cakephp,一切正常。没有错误。我将debug改为0,突然我的页面出现404个错误,在我的日志中,我注意到我在app controller中声明的、以前工作正常的变量现在又返回为未定义的变量 古怪。为什么将调试更改为0会导致这种行为 编辑:2012年4月18日 我翻了翻页面控制器。在$path=func\u get\u参数之后;当我投进一个dieprint_r$路径时。使用debug 1或debug 2,它会在我的主页上返回以下内容: Array ( [0] => home ) “调试”设置
Array
(
[0] => home
)
“调试”设置为0时为空
以下是我的一些路线:
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::connect('/login', array('controller' => 'users', 'action' => 'login'));
Router::connect('/logout', array('controller' => 'users', 'action' => 'logout'));
Router::connect('/today', array('controller' => 'users', 'action' => 'today'));
Router::connect('/profile', array('controller' => 'users', 'action' => 'profile'));
$staticPages = array(
'about',
'contact'
);
$staticList = implode('|', $staticPages);
Router::connect('/:static', array(
'plugin' => false,
'controller' => 'pages',
'action' => 'display'), array(
'static' => $staticList,
'pass' => array('static')
)
);
从调试日志:
2012-04-17 10:28:08 Notice: Notice (8): Undefined variable: loggedIn in [/Users/conrad/Desktop/Creative/DEV/virtutrain/app/View/Elements/Header.ctp, line 3]
Trace:
include - APP/View/Elements/Header.ctp, line 3
View::_evaluate() - CORE/Cake/View/View.php, line 908
View::_render() - CORE/Cake/View/View.php, line 872
View::element() - CORE/Cake/View/View.php, line 412
include - APP/View/Layouts/default.ctp, line 22
View::_evaluate() - CORE/Cake/View/View.php, line 908
View::_render() - CORE/Cake/View/View.php, line 872
View::renderLayout() - CORE/Cake/View/View.php, line 527
View::render() - CORE/Cake/View/View.php, line 471
Controller::render() - CORE/Cake/Controller/Controller.php, line 959
ExceptionRenderer::_outputMessage() - CORE/Cake/Error/ExceptionRenderer.php, line 263
ExceptionRenderer::error400() - CORE/Cake/Error/ExceptionRenderer.php, line 209
ExceptionRenderer::render() - CORE/Cake/Error/ExceptionRenderer.php, line 165
ErrorHandler::handleException() - CORE/Cake/Error/ErrorHandler.php, line 127
[main] - [internal], line ??
错误日志:
2012-04-17 10:28:08 Error: [NotFoundException] Not Found
#0 /Users/conrad/Desktop/Creative/DEV/virtutrain/lib/Cake/View/View.php(908): include()
#1 /Users/conrad/Desktop/Creative/DEV/virtutrain/lib/Cake/View/View.php(872): View->_evaluate('/Users/conrad/D...', Array)
#2 /Users/conrad/Desktop/Creative/DEV/virtutrain/lib/Cake/View/View.php(463): View->_render('/Users/conrad/D...')
#3 /Users/conrad/Desktop/Creative/DEV/virtutrain/lib/Cake/Controller/Controller.php(959): View->render('about', NULL)
#4 /Users/conrad/Desktop/Creative/DEV/virtutrain/app/Controller/PagesController.php(88): Controller->render('about')
#5 [internal function]: PagesController->display('about')
#6 /Users/conrad/Desktop/Creative/DEV/virtutrain/lib/Cake/Controller/Controller.php(485): ReflectionMethod->invokeArgs(Object(PagesController), Array)
#7 /Users/conrad/Desktop/Creative/DEV/virtutrain/lib/Cake/Routing/Dispatcher.php(103): Controller->invokeAction(Object(CakeRequest))
#8 /Users/conrad/Desktop/Creative/DEV/virtutrain/lib/Cake/Routing/Dispatcher.php(85): Dispatcher->_invoke(Object(PagesController), Object(CakeRequest), Object(CakeResponse))
#9 /Users/conrad/Desktop/Creative/DEV/virtutrain/app/webroot/index.php(96): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#10 {main}
再次。。。当调试为1或2时,不会出现任何错误
此安装正在MAMP上本地运行,但在MediaTemple的网格服务上运行的已发布站点上也会出现错误,该站点或多或少都有默认设置。Wow。。。该文件位于my home.ctp页面视图中,并被复制到所有其他页面:
if (Configure::read('debug') == 0):
throw new NotFoundException();
endif;
主要wtf,但不管怎样。。。问题已解决。以前从未遇到或见过此问题。你能提供更多的信息吗?路由配置、核心设置、服务器配置等。您跟踪的错误显示$loggedIn不存在,但这是因为它生成了404错误,因为可能找不到控制器/操作,并且可能跳过了设置变量的代码。关闭调试并转到同一url,异常/错误应该更具体;当我打开debug时,绝对不会抛出或记录任何错误,而且一切都很正常。缓存可能与此有关吗?当调试>0时,缓存关闭。尝试手动清除app/temp文件夹内容。已清除缓存,无更改。在关闭调试的情况下引发异常的原因是。添加此评论以帮助通过搜索到达此处的用户。