所以,我正在使用MyBB论坛,我去调节一个线程,并得到这个错误。
Fatal error: Using $this when not in object context in C:\zpanel\hostdata\sdcore\public_html\forums\inc\class_moderation.php on line 642
第642行的代码是
$this->delete_thread($mergetid);
周围的代码(以防万一)
$db->delete_query("threadsubscriptions", "tid = '{$mergetid}'");
update_first_post($tid);
$arguments = array("mergetid" => $mergetid, "tid" => $tid, "subject" => $subject);
$plugins->run_hooks("class_moderation_merge_threads", $arguments);
$this->delete_thread($mergetid);
和删除线程函数
function delete_thread($tid)
{
global $db, $cache, $plugins;
$tid = intval($tid);
$plugins->run_hooks("class_moderation_delete_thread_start", $tid);
$thread = get_thread($tid);
$userposts = array();
// Find the pid, uid, visibility, and forum post count status
$query = $db->query("
SELECT p.pid, p.uid, p.visible, f.usepostcounts
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.tid='{$tid}'
");
$pids = array();
$num_unapproved_posts = $num_approved_posts = 0;
while($post = $db->fetch_array($query))
{
$pids[] = $post['pid'];
$usepostcounts = $post['usepostcounts'];
if(!function_exists("remove_attachments"))
{
require MYBB_ROOT."inc/functions_upload.php";
}
// Remove attachments
remove_attachments($post['pid']);
// If the post is unapproved, count it!
if($post['visible'] == 0 || $thread['visible'] == 0)
{
$num_unapproved_posts++;
}
else
{
$num_approved_posts++;
// Count the post counts for each user to be subtracted
++$userposts[$post['uid']];
}
}
// Remove post count from users
if($usepostcounts != 0)
{
if(is_array($userposts))
{
foreach($userposts as $uid => $subtract)
{
$db->update_query("users", array('postnum' => "postnum-{$subtract}"), "uid='".intval($uid)."'", 1, true);
}
}
}
// Delete posts and their attachments
if($pids)
{
$pids = implode(',', $pids);
$db->delete_query("posts", "pid IN ($pids)");
$db->delete_query("attachments", "pid IN ($pids)");
$db->delete_query("reportedposts", "pid IN ($pids)");
}
// Implied counters for unapproved thread
if($thread['visible'] == 0)
{
$num_unapproved_posts += $num_approved_posts;
}
// Delete threads, redirects, subscriptions, polls, and poll votes
$db->delete_query("threads", "tid='$tid'");
$db->delete_query("threads", "closed='moved|$tid'");
$db->delete_query("threadsubscriptions", "tid='$tid'");
$db->delete_query("polls", "tid='$tid'");
$db->delete_query("pollvotes", "pid='".$thread['poll']."'");
$db->delete_query("threadsread", "tid='$tid'");
$db->delete_query("threadratings", "tid='$tid'");
$updated_counters = array(
"posts" => "-{$num_approved_posts}",
"unapprovedposts" => "-{$num_unapproved_posts}"
);
if($thread['visible'] == 1)
{
$updated_counters['threads'] = -1;
}
else
{
$updated_counters['unapprovedthreads'] = -1;
}
if(substr($thread['closed'], 0, 5) != "moved")
{
// Update forum count
update_forum_counters($thread['fid'], $updated_counters);
}
$plugins->run_hooks("class_moderation_delete_thread", $tid);
return true;
}
我将如何解决这个问题?