【问题标题】:Joomla error with content deletions after upgraded php 7.4 [closed]升级 php 7.4 后内容删除的 Joomla 错误 [关闭]
【发布时间】: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 兼容?除此之外,消息很清楚——插件代码需要三个参数,但它只得到两个。如果是你的代码调用它,你需要弄清楚额外的参数应该是什么并提供它。
  • 感谢您的回答。我编辑了我的第一篇文章。现在它似乎工作正常。没有警告或错误。内容删除有效。

标签: php arrays joomla php-7


【解决方案1】:

还不能评论:

查看 php 文档,方法 call_user_func_array 没有三个参数。 https://www.php.net/manual/de/function.call-user-func-array.php

我会假设第一个应该包含类 ($this) 和可调用方法名称($event 中的值)的数组是无效的。

您是否联系了插件的开发人员?他应该为您提供一个更新的版本,它与 PHP 7 兼容。

【讨论】:

  • 感谢您的回答。我用解决方案编辑了我的第一篇文章。需要更多测试,但现在似乎可以了。
猜你喜欢
  • 2023-01-23
  • 2020-10-29
  • 1970-01-01
  • 2021-09-29
  • 2020-12-29
  • 2020-03-26
  • 2018-05-24
  • 1970-01-01
相关资源
最近更新 更多