6

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.

Community
  • 1
  • 1
Deadlock
  • 1,575
  • 1
  • 19
  • 34

2 Answers2

8

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
));
Scrappy Cocco
  • 1,192
  • 3
  • 21
  • 38
4

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.

CptAJ
  • 1,156
  • 1
  • 13
  • 20
  • I searched the entire project for error_reporting and replaced it with error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED); until I got no errors. – Sela Yair Jan 13 '17 at 15:21