Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 342
Deadlock Avatar asked Jan 14 '13 05:01

Deadlock


2 Answers

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
));
like image 124
Scrappy Cocco Avatar answered Nov 09 '22 15:11

Scrappy Cocco


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.

like image 45
CptAJ Avatar answered Nov 09 '22 16:11

CptAJ