Deadlock
Deadlock

Reputation: 1577

Static Standards error after updating to php 5.4.9

I am getting following errors after updating php to version 5.4

Strict Standards: Non-static method Debugger::invoke() should not be called statically, assuming $this from incompatible context in /usr/share/php/cake/libs/debugger.php on line 575 
Strict Standards: Non-static method Debugger::getInstance() should not be called statically, assuming $this from incompatible context in /usr/share/php/cake/libs/debugger.php on line 575

I have already tried following solutions

Error while Disabling error reporting in CakePHP

Cakephp doesn't work after installing php5-curl package (Unable to locate "Cake" folder as I have baked my project)

Wampserver cakephp 1.3 Strict standards error

How to eliminate php5 Strict standards errors?

PHP 5 disable strict standards error

https://stackoverflow.com/questions/11799085/turn-off-php-strict-standards?lq=1 (Was not able to turn off the errors)

Cleared cake cache, web browser cache, cookies and restarted server after each change. Even tried in private browsing and chrome, firefox, ie also.

Upvotes: 6

Views: 11034

Answers (3)

rubo77
rubo77

Reputation: 20845

The best option would be to update CakePHP to the latest version, where this is fixed for PHP 8 already. But if that's not possible, you have to add static to all functions that are called with double colon ::

static function invoke(&$debugger) {
        set_error_handler(array(&$debugger, 'handleError'));
    }
}

Upvotes: 0

CptAJ
CptAJ

Reputation: 1166

Changing the error_reporting function does work to fix this. However, cakephp seems to set these flags in several places, that's why the solution may not have worked for you (I went through the same)

Do a source-wide search for "error_reporting" and you'll find it used in several files. Add the flag "~E_STRICT" wherever you can. For instance:

error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);

You'll see it in places like /cake/bootstrap.php, /cake/libs/configure.php, /cake/console/cake.php, etc. I just changed them all to exclude E_STRICT and the problem was fixed.

Upvotes: 4

Scrappy Cocco
Scrappy Cocco

Reputation: 1204

I believe this is because this app is built on an older version of CakePHP, which may use some deprecated functions. It'd be awesome if you (or someone else) could upgrade Cake to a new stable branch. As of now try this in your core.php you could remove the E_STRICT from your error reporting:

i.e go to app/Config/core.php find

Configure::write('Error', array(
    'handler' => 'ErrorHandler::handleError',
    'level' => E_ALL & ~E_DEPRECATED,
    'trace' => true
));

replace it as

Configure::write('Error', array(
    'handler' => 'ErrorHandler::handleError',
    'level' => E_ALL & ~E_STRICT & ~E_DEPRECATED,
    'trace' => true
));

Upvotes: 8

Related Questions