Fatal error: Call to undefined method Action::execute() /home/public_html/system/engine/event.php on line 62

試著忘記壹切 提交于 2019-12-02 16:03:00

问题


Hi tried refreshing the modification cache cache in opencart and since then i am getting a blank page in front end with this error message.

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;
            }
        }
    }
}

Thanks,


回答1:


It seems your have an OC version 3.0.2.x or above.

In your $this->data of the Event Class, you have an event registered that is missing an action parameter.

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

All events are registered via the register() method which explicitly requests that an Action object is being passed as a parameter.

Since the error is pointing to "Call to undefined method Action::execute()", I can assume, you have an issue with the action class.

Most likely you need to check the Modifications of the system/engine/action.php file in your system/storage/modifications.

It could be that the method execute() is either missing or somehow corrupt.

Debug

try to var_dump the $value to see what is there:

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;
            }
        }
    }
}

Hope this helps



来源:https://stackoverflow.com/questions/56324444/fatal-error-call-to-undefined-method-actionexecute-home-public-html-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!