【发布时间】:2011-04-22 23:11:07
【问题描述】:
在functions.php中我有这个:
add_action('comment_post', 'comment_posted');
function comment_posted() {
$MyClass = new MyClass(); //if I comment this line out the problem goes away
}
评论发布成功,但浏览器卡在一个白页上,其 url 如下所示:
http://mydomain.com/wp-comments-post.php#comment-33
在萤火虫中我可以看到:405 Method Not Allowed
我需要在 MyClass php 文件中进行调用,所以我需要它。我在functions.php中的其他函数中使用了该类,所以我不明白为什么在这种情况下会导致黑屏。
编辑 - MyClass 构造函数:
public function __construct()
{
$this->someVar='abc';
mysql_connect("localhost", "dbname", "pwd");
mysql_select_db("somedb");
}
【问题讨论】:
-
在 Firebug 中你能看到用来发表评论的 HTTP 方法吗? GET、POST、PUT 等
-
...您将多少个 cmets 标记为垃圾邮件?如果有负载尝试删除它们(有一个“清除垃圾邮件”按钮)
-
我看到 POST wp-cmets-post.php 和 GET wp-cmets-post.php#comment-33
-
MyClass的构造函数是做什么的? -
投票 - 当我注释掉 MyClass 构造函数中的 3 行时,它起作用了!问题是我需要这 3 行。在上面添加它们。