【发布时间】:2015-10-26 08:26:59
【问题描述】:
抱歉,如果这是 真正的 基本的,但是当 PHP 进入函数时,我无法理解。
我有一个论坛插件,它加载一个 flash cookie 作为检测重复帐户的方法。
脚本在大约 0.1% 的页面浏览量上失败,导致 WSOD。错误指向这一行:
return $this->registry->output->getTemplate( 'dml' )->duplicatesLoadMovie( $host, $path, $id, $md5 );
错误信息是:
致命错误:在第 75 行的 /var/www/.../web/forums/hooks/duplicatesLoadMovie.php 中的 null 上调用成员函数 duplicatesLoadMovie()
对我来说,这读作 $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 );
}
【问题讨论】:
标签: php