CakePHP 1.2 and PHP 5.3 doesn’t play nice

I just upgraded all the software only to discover PHP got upgraded to 5.3. That’s fast, PHP 5.3 isn’t out too long ago and it’s in the Macosforge repository. Even the CakePHP update released on August 9 did not include PHP 5.3 compatibility.

Perhaps it’s time to update the CakePHP requirements and be indicative of the lack of support for PHP 5.3.

Now the library is throwing deprecated notices all around “Assigning the return value of new by reference is deprecated in…”. Also there is a PHP warning:

[code lang=”php”]PHP Warning: strtotime(): It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘Asia/Singapore’ for ‘SGT/8.0/no DST’ instead in…[/code]

To stop the deprecated notices, I had to modify Cake’s core, not something I like to do.

I added the line “error_reporting (E_ALL & ~E_DEPRECATED);” at the top of /cake/libs/object.php. I also updated /cake/libs/configure.php by changing “error_reporting(E_ALL);” to “error_reporting (E_ALL & ~E_DEPRECATED);”.


This doesn’t solve the problem exactly, it just suppresses the deprecation notices so I can continue working. For a PHP 5.3 compatible CakePHP, you’ll need to use CakePHP 1.3 which currently isn’t stable. I’ll definitely be trying it soon but in the meantime I’ll just have to suppress error reporting.

Update: jdbartlett commented on a better way:

[code lang=”php”]if (defined(“E_DEPRECATED”)) error_reporting(E_ALL ^ E_DEPRECATED);[/code]

If you’re not doing any debugging, you can add the above code to the top of /app/webroot/index.php and suppress the error messages without editing the core. :)

Thanks jdbartlett! You saved me time. :)