0

当我在基于 CakePHP 1.2.10 的应用程序中使用主题视图时,它会出现以下症状:

  1. favicon 不会在源中打印出来。
  2. 生成以下警告:

    警告 (2):array_merge() [function.array-merge]:参数 #2 不是数组 [ROOT\cakephp\cake\libs\router.php,第 754 行]

    警告 (2):extract() 期望参数 1 为数组,给定 null [ROOT\cakephp\cake\libs\router.php,第 754 行]

    注意(8):未定义变量:escape [ROOT\cakephp\cake\libs\router.php,第 930 行]

所有这些警告和通知都提到:

[主要] - APP\webroot\index.php,第 87 行

该文件的第 87 行在以下代码中

if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
        return;
    } else {
        $Dispatcher = new Dispatcher(); 
        $Dispatcher->dispatch($url);//This is line 87
    }
    if (Configure::read() > 0) {
        echo "<!-- " . round(getMicrotime() - $TIME_START, 4) . "s -->";
    }
//Here is the end of the file APP\webroot\index.php
?>

我的应用程序包含应用程序目录中的 CakePHP 库。即我所有应用程序的一个蛋糕。

当我切换到非主题视图时,所有这些警告都消失了。我想知道为什么我会收到这些警告?以及我该如何解决它们。

4

1 回答 1

0

我发现这个错误是由于对 $html->url() 方法的错误调用造成的。我被称为 $this->url('/img/logo.png', "full"),但它应该是 $html->url('/img/logo.png', true)。

该调用来自一个名为 head.ctp 的元素文件。以下是完整的比赛警告说明:

array_merge - [internal], line ??
Router::url() - ROOT\cakephp\cake\libs\router.php, line 754
Helper::url() - ROOT\cakephp\cake\libs\view\helper.php, line 177
include - APP\views\themed\slate\elements\head.ctp, line 15 //HERE IS THE Mistaken Call
View::_render() - ROOT\cakephp\cake\libs\view\view.php, line 665
View::element() - ROOT\cakephp\cake\libs\view\view.php, line 342
include - APP\views\themed\slate\layouts\blog.ctp, line 1
View::_render() - ROOT\cakephp\cake\libs\view\view.php, line 665
View::renderLayout() - ROOT\cakephp\cake\libs\view\view.php, line 453
View::render() - ROOT\cakephp\cake\libs\view\view.php, line 387
Controller::render() - ROOT\cakephp\cake\libs\controller\controller.php, line 808
Dispatcher::_invoke() - ROOT\cakephp\cake\dispatcher.php, line 229
Dispatcher::dispatch() - ROOT\cakephp\cake\dispatcher.php, line 193
[main] - APP\webroot\index.php, line 88
Warning (2): extract() expects parameter 1 to be array, null given [ROOT\cakephp\cake\libs\router.php, line 754]
Notice (8): Undefined variable: escape [ROOT\cakephp\cake\libs\router.php, line 930
于 2013-04-06T02:28:01.787 回答