道歉,如果这是真正的基础,但是当PHP进入函数时,我就不知所措了。
我有一个论坛插件,该插件加载Flash Cookie作为检测重复帐户的一种方法。
该脚本在大约0.1%的页面视图上失败,从而导致WSOD。错误指向此行:
return $this->registry->output->getTemplate( 'dml' )->duplicatesLoadMovie( $host, $path, $id, $md5 );
Run Code Online (Sandbox Code Playgroud)
错误是:
致命错误:在第75行的/var/www/.../web/forums/hooks/duplicatesLoadMovie.php中,调用成员函数plicatesLoadMovie()时为null
对我来说,这个读为一体的$host,$path,$id,或$md5正在恢复null,但因为这不是我的脚本(及编码器,当然,反应迟钝),我想可能最简单的方法来解决这个问题(除了删除它,这是后备位置)。
我可以简单地做些什么来达到效果$id = 0 if id.null吗?(对不起Rubyspeak)每个$variables?
文件的完整来源:
class duplicatesLoadMovie
{
/**
* Registry object shortcuts
*
* @var $registry
* @var $settings
* @var $member
* @var $memberData
**/
public $registry;
public $settings;
public $member;
public $memberData;
/**
* Main function executed automatically by the controller
*
* @access public
* @return @e void
**/
public function __construct()
{
$this->registry = ipsRegistry::instance();
$this->settings =& $this->registry->fetchSettings();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
}
/**
* Get the output
*
* @access public
* @return @e string
**/
public function getOutput()
{
/* Grab host URL and installation path of the community */
$host = $this->settings['board_url'];
$parsed = parse_url( $host );
$path = trim( $parsed['path'], '/' );
if( $path == '' )
{
$path = '/';
}
$host = 'host=' . $host;
$path = 'path=' . $path;
/* Determine the appropriate identification method (member_id for members and session_id for guests) */
if( $this->memberData['member_id'] )
{
$id = 'mid=' . $this->memberData['member_id'];
}
else
{
$id = 'sid=' . $this->member->session_id;
}
/* Grab the secure key for AJAX */
$md5 = 'md5=' . $this->member->form_hash;
/* Finally, call the template bit */
return $this->registry->output->getTemplate( 'dml' )->duplicatesLoadMovie( $host, $path, $id, $md5 );
}
Run Code Online (Sandbox Code Playgroud)
我怀疑这getTemplate( 'dml' )没有返回值。如果你做了 a var_dump(getTemplate( 'dml' )),它会显示什么吗?
您可以在执行该行代码之前检查“null”,并在“else”语句中输出错误消息或适合该错误的其他操作。