gpt4 book ai didi

cakephp - 为什么在 CakePHP 中将 debug 更改为 0 会破坏静态页面?

转载 作者:行者123 更新时间:2023-12-04 05:49:57 25 4
gpt4 key购买 nike

一切正常。没有错误。我将 debug 更改为 0,突然间我的页面出现了 404 错误,并且在我的日志中,我注意到我在应用程序 Controller 中声明的变量(之前运行良好)现在返回未定义。

怪异。为什么将 debug 更改为 0 会导致这种行为?

编辑:2012 年 4 月 18 日

我在 Pages Controller 周围闲逛。在“$path = func_get_args();”之后当我 throw 骰子时(print_r($path))。使用调试 1 或 2,它会在我的主页上返回:

Array
(
[0] => home
)

当 debug 设置为 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 网格服务(具有或多或少的默认设置)上的已发布站点上。

最佳答案

哇...这是坐在我的 home.ctp 页面 View 中,并被复制到所有其他页面:

if (Configure::read('debug') == 0):
throw new NotFoundException();
endif;

主要wtf,但无论如何......问题解决了。

关于cakephp - 为什么在 CakePHP 中将 debug 更改为 0 会破坏静态页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10192997/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com