Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in moxiemanager with PHP7

After updating the version from PHP5 to PHP7, an error appears when trying to insert images from the moxiemanager plugin of the tinymce that I have integrated into the project.

just tell me: Error: Array to string conversion

like image 992
Jesus Guevara Avatar asked Jun 29 '18 20:06

Jesus Guevara


1 Answers

After a few hours, I could find the error

Specifically in: /home/user/website/admin/js/vendor/tinymce/plugins/moxiemanager/classes/Util/EventDispatcher.php:118

In the method:

public function dispatch($sender, $name, $args) {
    $name = strtolower($name);

    if (isset($this->observers[$name])) {
        $observers = $this->observers[$name];
        $args->setSender($sender);

        for ($i = 0, $l = count($observers); $i < $l; $i++) {
            $value = $observers[$i][1]->$observers[$i][0]($args);

            // Is stopped then break the loop
            if ($value === false || $args->isStopped()) {
                return $args;
            }
        }
    }

    return $args;
}

you must replace the following line:

$value = $observers[$i][1]->$observers[$i][0]($args);

For this:

$value = $observers[$i][1]->{$observers[$i][0]}($args);

PHP7 uses an abstract syntactic tree when analyzing the source files. Indirect access to variables, properties and methods will now be strictly evaluated from left to right.

like image 81
Jesus Guevara Avatar answered Nov 17 '22 13:11

Jesus Guevara