2012-03-11 121 views
4

警告:参数3至showBlogSection()预计是一个参考,在线路中/home/smartsta/public_html/includes/Cache/Lite/Function.php给定值100的Joomla PHP错误

我在突然间在我的Joomla网站的内容区域显示上述错误,有什么建议吗?

更新:没有这样的运气找到GoDaddy的FTP文件目录,FTP或Joomal C-面板内访问定义的文件和目录。 在FTP中,我无法找到访问此特定文件的内容来调查第100行。 在Joomla面板的全局配置中,我能够将'错误信息'切换为none,至少可以隐藏此错误。在缓存目录中,我看不到进入该文件夹的任何选项,尽管它显示。 我也看到了这个在c面板屏幕的底部,但只是链接到一个joomla帮助网站,并在字段内我没有看到描述区域切换'打开或关闭' “以下的PHP服务器设置不是最佳的安全和建议进行修改:中 PHP register_globals的设置为ON,而不是OFF

UPDATE2!:

我发现有问题的文件,下面是代码。第100行仅表示:

global $$ object_123456789;

应用程序/ X的httpd - PHP Function.php PHP脚本文本

<?php 

/** 
* This class extends Cache_Lite and can be used to cache the result and output of functions/methods 
* 
* This class is completly inspired from Sebastian Bergmann's 
* PEAR/Cache_Function class. This is only an adaptation to 
* Cache_Lite 
* 
* There are some examples in the 'docs/examples' file 
* Technical choices are described in the 'docs/technical' file 
* 
* @package Cache_Lite 
* @version $Id: Function.php 47 2005-09-15 02:55:27Z rhuk $ 
* @author Sebastian BERGMANN <[email protected]> 
* @author Fabien MARTY <[email protected]> 
*/ 

// no direct access 
defined('_VALID_MOS') or die('Restricted access'); 

require_once($mosConfig_absolute_path . '/includes/Cache/Lite.php'); 

class Cache_Lite_Function extends Cache_Lite 
{ 

    // --- Private properties --- 

    /** 
    * Default cache group for function caching 
    * 
    * @var string $_defaultGroup 
    */ 
    var $_defaultGroup = 'Cache_Lite_Function'; 

    // --- Public methods ---- 

    /** 
    * Constructor 
    * 
    * $options is an assoc. To have a look at availables options, 
    * see the constructor of the Cache_Lite class in 'Cache_Lite.php' 
    * 
    * Comparing to Cache_Lite constructor, there is another option : 
    * $options = array(
    * (...) see Cache_Lite constructor 
    * 'defaultGroup' => default cache group for function caching (string) 
    *); 
    * 
    * @param array $options options 
    * @access public 
    */ 
    function Cache_Lite_Function($options = array(NULL)) 
    { 
     if (isset($options['defaultGroup'])) { 
      $this->_defaultGroup = $options['defaultGroup']; 
     } 
     $this->Cache_Lite($options); 
    } 

    /** 
    * Calls a cacheable function or method (or not if there is already a cache for it) 
    * 
    * Arguments of this method are read with func_get_args. So it doesn't appear 
    * in the function definition. Synopsis : 
    * call('functionName', $arg1, $arg2, ...) 
    * (arg1, arg2... are arguments of 'functionName') 
    * 
    * @return mixed result of the function/method 
    * @access public 
    */ 
    function call() 
    { 
     $arguments = func_get_args(); 
     $id = serialize($arguments); // Generate a cache id 
     if (!$this->_fileNameProtection) { 
      $id = md5($id); 
      // if fileNameProtection is set to false, then the id has to be hashed 
      // because it's a very bad file name in most cases 
     } 
     $data = $this->get($id, $this->_defaultGroup); 
     if ($data !== false) { 
      $array = unserialize($data); 
      $output = $array['output']; 
      $result = $array['result']; 
     } else { 
      ob_start(); 
      ob_implicit_flush(false); 
      $target = array_shift($arguments); 
      if (strstr($target, '::')) { // classname::staticMethod 
       list($class, $method) = explode('::', $target); 
       $result = call_user_func_array(array($class, $method), $arguments); 
      } else if (strstr($target, '->')) { // object->method 
       // use a stupid name ($objet_123456789 because) of problems when the object 
       // name is the same as this var name 
       list($object_123456789, $method) = explode('->', $target); 
       global $$object_123456789; 
       $result = call_user_func_array(array($$object_123456789, $method), $arguments); 
      } else { // function 
       $result = call_user_func_array($target, $arguments); 
      } 
      $output = ob_get_contents(); 
      ob_end_clean(); 
      $array['output'] = $output; 
      $array['result'] = $result; 
      $this->save(serialize($array), $id, $this->_defaultGroup); 
     } 
     echo($output); 
     return $result; 
    } 

} 

?> 
+1

当您查看100行上的/home/smartsta/public_html/includes/Cache/Lite/Function.php时,您在那看到了什么?你应该记录错误而不是显示它们,所以它们不会出现在页面中。 – hakre 2012-03-11 15:31:21

+0

我还没有检出文件,但在这个'突然出错'之前,代码中没有任何错误。是否有可能出现在线路100上?我该如何记录错误,使它们不会出现在页面中? – 2012-03-11 15:42:18

+0

感谢您的回应! – 2012-03-11 15:43:04

回答

7

这是不完全的错误。这是一个警告

突然?也许你已经升级/更新你的PHP版本。或者将PHP配置更改为“严格模式”。

消息“预期为基准,给定值”是指预期用于接收参考,而不是一个所调用的函数。看:在$parameter

function show_section(&$parameter) { 
    $parameter = 'changed!'; 
} 
  1. 注意连字符&

    $something = 9; 
    show_section($something); 
    // here you are passing a variable 
    // this will be accepted as a reference 
    
    show_section(9); 
    // here you are NOT passing a reference 
    // here you are passing a VALUE 
    

    当您通过“参照”,该功能可以改变变量的值...在上面的例子 - 这是我们如何指定一个功能需要参考。

  2. 在函数调用之后,在上面的示例中,变量$something的值将是changed!字符串。


行引发错误是不是 “全球” 之一。这是下一个:

$result = call_user_func_array(array($$object_123456789, $method), $arguments); 

的这里的问题是,该功能正在被使用“call_user_func_array”功能间接调用。

解决方案将转换所有参数到引用。建议:

foreach ($arguments as $count => $value) 
{ 
    $param = 'param' . $count; 
    $$param = $value; 
    $arguments[$count] = &$$param; 
} 

把上面的代码中call函数的开始,右以下行:

$id = serialize($arguments); 

试试这个!

+0

非常感谢回复并帮助我理解。你对解决方案有任何建议吗? – 2012-03-11 19:47:20

+0

@ cam77:刚刚添加了一个解决方案 - 我认为它的工作原理... :)请,测试 – 2012-03-11 19:51:24

+0

您先生,是人类已知的最大救生员。谢谢!!! – 2012-03-11 19:53:59