Skip to main content

Blog Post

Getting your Drupal 6 site ready to run on PHP 5.6

The Drop isn't the only thing that is moving; so is PHP. If you have a Drupal 6 site you are most likely running PHP 5.3 or older, versions that stopped being supported in 2014 or prior. Now that PHP 5.5 has moved out of active support, some hosts, such as Acquia, are dropping support for anything older and sites will be forced to upgrade, ready or not. The good news is that Drupal 6 can be made to work with PHP 5.6, which is actively supported. Drupal 6 core needs just a few patches but many contributed modules will need to be updated and/or patched.

GET A BASELINE

So what patches and updates does your site need? To find out, you first want to get a list of what errors your site is producing now. If you have dblog running and your watchdog table is empty, you can skip this step. If your site is like most, though, there are a bunch of little errors that will fill the logs and make it difficult to see what problems the upgrade is causing. To make a baseline list:

  • Make sure the dblog module is enabled.
  • Truncate the watchdog table to clear out old errors so we just have the current ones. (Be sure to keep a backup if you have a need for the original error log.)
  • Spider the site as an admin to hit all of the pages, including the admin section. I used wget for it following these instructions from jesstess:
    wget --post-data='edit-name=USERNAME&edit-pass=PASSWORD&next=' --save-cookies=cookies.txt --keep-session-cookies http://EXAMPLE.COM/user
    wget -R logout -r --spider --load-cookies=cookies.txt --save-cookies=cookies.txt --keep-session-cookies http://EXAMPLE.COM
    
  • Try out some manual things that the spider won't hit like saving a node or editing an existing one.
  • Put this script into a text file called watchdog_distinct.php (you will need to add an opening php tag at the top):
    $result = db_query("SELECT DISTINCT message, variables, location FROM {watchdog} WHERE type = 'php' GROUP BY message, variables");
    
    while ($row = db_fetch_object($result)) {
      if (isset($row->message) && isset($row->variables)) {
        if ($row->variables === 'N;') {
          $message = $row->message;
        }
        else {
          $message = t($row->message, unserialize($row->variables));
        }
    
        drush_print($row->location . ' ~ ' . $message);
        drush_print("");
      }
    }
    
  • Run the following command via your terminal or command prompt (note: requires the Drush system to be installed):
    drush scr watchdog_distinct.php > current_errors.txt

The text file, current_errors.txt will now contain a list of the errors your site is currently having that you can compare against.

UPGRADE AND SEE WHAT BREAKS

Now that you have a baseline to compare against, it's time to upgrade and find out what breaks. Do the following steps on a development copy of your site.

  • (optional) Upgrade core and contrib to the newest versions. This isn't strictly required and you could get by only upgrading those that turn out to need an upgrade to work with PHP 5.6. However, this is a good time to get your site completely up to date and the newest versions of contrib modules are most likely to have the necessary fixes.
  • Apply known patches to the modules you are using. See the references section below for links to the three PHP upgrade issue tags on drupal.org.
  • Set your development site to run on PHP 5.6.
  • Go through the same process as above with truncating watchdog, spidering, and running the script, but give the results text file a new name.
  • Compare the errors in the new text file to those in the old one to see what is broken that wasn't broken before.
  • For each of the errors, check for patches or write your own. Make sure to contribute back any patches you make and to tag them with the PHP version number to help others find them.
  • Repeat the testing, patching, and fixing until no new errors occur.
  • Give your site a good manual going over to spot anything the spider missed.

Once this process is completed with no new errors showing – congratulations, your site is now ready to handle PHP 5.6!

References

Michelle Cox

Meet team member, Michelle Cox

Michelle started using Drupal in 2005 with the 4.6 release. She spent the next seven years actively participating in the community by writing and maintaining three contributed modules, assisting in...

Learn more about Michelle >

Related Insights

Access icon Up arrow icon Drupal 8 icon Facebook icon - white Facebook icon - blue outline Facebook icon - yellow Hollow right arrow icon Hollow right arrow icon - white LinkedIn icon - white LinkedIn icon - hollow LinkedIn icon - blue outline LinkedIn icon - yellow Mediacurrent wordmark Quote icon Twitter icon - white Twitter icon - hollow Twitter icon - blue outline Twitter icon - yellow Youtube icon - white Youtube icon - yellow