You are here

Drupal and PHP 5.3

There are some problems with running Drupal on php 5.3. There are five kinds of solutions:

  1. Downgrade to php 5.2.6 (not possible in many situations)
  2. modify Drupal to change the error level reporting
  3. find the latest patches to fix the problems
  4. hack Drupal core or contrib yourself to fix the errors (Drupal 6 is already compliant, but not D5)
  5. put a timezone in your php.ini to get rid of timezone errors

Drupal 6

2. Modify Drupal's error reporting --already done for Drupal 6

3. Find patches

Module Patch Issue Queue
imageapi imageapi_540486.patch
calendar calendar-6.x-2.2-613528-5.patch
date date-6.x-2.x-549884-30.patch
views views-6.x-2.7-php53-1.patch
admin_menu 615058-adminmenu-php53-D6-1.patch
rules rules_php53fixes2.patch

Any error that looks like: unexpected $end, expecting TC_DOLLAR_CURLY or TC_QUOTED_STRING that references a .ini file can be fixed by putting quotes around the description in that file to comply with php syntax rules for .ini files.

5. Set timezone in php.ini --same process for Drupal 5 and 6

Explicitly set the timezone in php.ini by uncommenting the line that contains date.timezone and adding a zone. e.g.:
date.timezone = America/Toronto

Drupal 5

2. Modify Drupal's error reporting


However, if you prefer to keep PHP 5.3, you can always suppress the deprecated function errors. In Drupal’s includes/, find line 590. It should be listed as:

    if ($errno & (E_ALL ^ E_NOTICE)) {

Replace this line with:

    if ($errno & (E_ALL & ~E_NOTICE & ~E_DEPRECATED)) {

This will now always suppress the Deprecated error messages.  If you have the developer tools module, you’ll need to make the same change to devel/devel.module line 460.

Note: Every time you update Drupal or the Devel module you’ll have to manually make this change until they finally  both support php 5.3.

Here is the patch that was done on Drupal 6:

3. Find patches

Here is my big patch to fix everything:
Other things that will need to be done in contrib:
Quotes around the description in many of the .info files including the following:

I have posted a patch on here:

views_rss.module needs a patch to views_rss_views_feed_argument so that the second argument is not a reference

Also Google Analytics has a line that need replacing:
-$p = module_invoke('profile', 'load_profile', $user);
+$p = call_user_func('profile_load_profile', $user);

4. Fix errors

This comment: suggests replacing ereg() with mb_ereg()
However, the official replacement is: preg_match() see:
Here is some discussion on patching Drupal:
This solution would probably need a lot of work, and maintenance re-applying patches for each update of Drupal