【问题标题】:Fatal error: Call to undefined method Action::execute() /home/public_html/system/engine/event.php on line 62致命错误:第 62 行调用未定义方法 Action::execute() /home/public_html/system/engine/event.php
【发布时间】:2019-10-12 22:24:32
【问题描述】:

您好尝试刷新 opencart 中的修改缓存缓存,从那时起我在前端得到一个空白页面,并显示此错误消息。

public function trigger($event, array $args = array()) {
        foreach ($this->data as $value) {
            if (preg_match('/^' . str_replace(array('\*', '\?'), array('.*', '.'), preg_quote($value['trigger'], '/')) . '/', $event)) {
                $result = $value['action']->execute($this->registry, $args);

            if (!is_null($result) && !($result instanceof Exception)) {
                return $result;
            }
        }
    }
}

谢谢,

【问题讨论】:

  • public function trigger($event, array $args = array()) { foreach ($this->data as $value) { if (preg_match('/^' . str_replace(array(' *', '\?'), array('.*', '.'), preg_quote($value['trigger'], '/')) . '/', $event)) { $result = $ value['action']->execute($this->registry, $args);
  • 什么错误信息?
  • 这是 phpMyAdmin 应用程序吗?为什么要标记它?

标签: php mysql sql phpmyadmin opencart


【解决方案1】:

您的 OC 版本似乎是 3.0.2.x 或更高版本。

在您的事件类$this->data 中,您注册了一个缺少操作参数的事件。

$this->data[] = array(
    'trigger'  => $trigger,
    'action'   => $action, // <-- this must be an Action Object with a method execute()
    'priority' => $priority
);

所有事件都通过register() 方法注册,该方法明确要求将Action 对象作为参数传递。

由于错误指向“调用未定义的方法 Action::execute()”,我可以假设,您的操作类有问题。

您很可能需要检查system/storage/modificationssystem/engine/action.php 文件的修改。

可能是 execute() 方法丢失或以某种方式损坏。

调试

尝试对 $value 进行 var_dump 以查看其中的内容:

public function trigger($event, array $args = array()) {
        foreach ($this->data as $value) {
//log out the $value before the error to see if the Action object is actually there and see what trigger causes this.
var_dump($value);
            if (preg_match('/^' . str_replace(array('\*', '\?'), array('.*', '.'), preg_quote($value['trigger'], '/')) . '/', $event)) {
                $result = $value['action']->execute($this->registry, $args);

            if (!is_null($result) && !($result instanceof Exception)) {
                return $result;
            }
        }
    }
}

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-17
    • 1970-01-01
    相关资源
    最近更新 更多