Notes on backporting modules from Drupal 6 to Drupal 5

| drupal

I needed a web statistics module for a Drupal-based project at work, and integrating an external web statistics module seemed to be the way to go in terms of performance and features. BAWstats integrates the popular AWstats web statistics analyzer into Drupal. The module was developed for Drupal 6, so I spent a few hours backporting it to Drupal 5. I don’t know if I can send a patch back (might have to do some paperwork), but anyway, here are some notes so that (a) I can remember how to do this in the future, and (b) it might save you some time.

Backporting from Drupal 6 to Drupal 5: Change the menu items

  • Move the menu path from the array key to the path attribute.
  • Rename

    page callback to callback and page arguments to callback arguments.

  • Remove the file and file path attributes. Move the included files to include_once lines for now, and look for instances of include that need to be changed to include_once. Read the included files to check for unintended execution.
  • Change tokenized menu items (%/%/%) to ones that dynamically build the menu path (arg(1) . ‘/’ . arg(2) . ‘/’ . arg(3)). Don’t forget – this shouldn’t be cached.
  • Change 'access arguments' => array( to 'access' => user_access( or something similar.

Those were most of the changes I needed to make in order to backport bawstats to Drupal 5. Seems to work so far… =) More notes when I run into other things!

You can comment with Disqus or you can e-mail me at sacha@sachachua.com.