Non-static method should not be called statically in Kohana 2.3.4

131 Views Asked by At

i've moved my Kohana 2.3.4 installation to a new hosting with php7 (probably that's a root of the issue) and now i am getting the following error:

Uncaught PHP Error: Non-static method AdminHook::menu_tree() should not be called statically in file system/core/Event.php on line 209

Here's my Event.php around line 209 (call_user_func($callback); is at line 209):

public static function run($name, & $data = NULL)
{
    if ( ! empty(self::$events[$name]))
    {
        // So callbacks can access Event::$data
        self::$data =& $data;
        $callbacks  =  self::get($name);

        foreach ($callbacks as $callback)
        {
            call_user_func($callback); // LINE 209
        }

        // Do this to prevent data from getting 'stuck'
        $clear_data = '';
        self::$data =& $clear_data;
    }

    // The event has been run!
    self::$has_run[$name] = $name;
}

And here's the AdminHook class:

class AdminHook {
    public function menu_tree(){
        $session = Session::instance();
        if(isset($_GET['_ml']) AND $_GET['_ml'] == 1) {
            $session->set('menuLink', 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
            //url::redirect(url::current());
        }
        global $menuLink;
        $menuLink = $session->get('menuLink');
    }
}

If i set menu_tree function to static, i get the following error:

Uncaught PHP Error: Declaration of Menu_Model::validate(array &$array, $save = false) should be compatible with ORM_Core::validate(Validation $array, $save = false) in file application/models/menu.php on line 18

I've been trying to find a solution for the next couple of days, but can't seem to find one. Any help is highly appreciated!

1

There are 1 best solutions below

0
bato3 On

Errors are not related to each other. By simply setting that method as static, php goes to showing the next error.

You have bad Menu_Model declaration. It mut be compatible with ORM_Core::validate

Menu_Model::validate(/*bad: array & */ Validation $array, $save = false)