2012-03-11 123 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