【发布时间】:2021-03-06 16:14:57
【问题描述】:
我刚刚在运行 Joomla 3.x 的服务器上将 php 5.6 升级到 7.4。
在我将 php 版本升级到 7.4 后,我遇到了问题。我无法以管理员身份删除任何内容(用户、文章、页面),出现此错误:
函数 plgContentFormLogger::onContentBeforeDelete() 的参数太少,在第 70 行的 /home/website/libraries/joomla/event/event.php 中传递了 2 个,而预期正好是 3 个
即使我将 php 版本降级到 7.3、7.2 甚至 7.1,问题仍然存在。有人可以帮助我吗,因为我无法弄清楚这一点?
代码:
public function update(&$args)
{
// First let's get the event from the argument array. Next we will unset the
// event argument as it has no bearing on the method to handle the event.
$event = $args['event'];
unset($args['event']);
/*
* If the method to handle an event exists, call it and return its return
* value. If it does not exist, return null.
*/
if (method_exists($this, $event))
{
return call_user_func_array(array($this, $event), $args); // line 70
}
}
当我像这样编辑这一行时,内容删除问题解决了:
return call_user_func_array(array($this, $event), $args, 0);
但之后我无法登录任何用户/用户角色。
问题暂时解决了。
在这个函数中我删除了$isNew
public function onContentBeforeDelete($context, $table, $isNew) {
$this->_log('onContentBeforeDelete', $context);
}
【问题讨论】:
-
PHP 主要版本之间的升级可能会引入向后不兼容的更改。您是否检查过您的插件是否与 PHP7 兼容?除此之外,消息很清楚——插件代码需要三个参数,但它只得到两个。如果是你的代码调用它,你需要弄清楚额外的参数应该是什么并提供它。
-
感谢您的回答。我编辑了我的第一篇文章。现在它似乎工作正常。没有警告或错误。内容删除有效。