Upgrading a Drupal 4.7.x site to 5.x
I recently had the potentially very painful task of upgrading a site from a hacked up version of Drupal 4.7.2 to the latest version of 5.x. Whilst I doubt theres many D4 sites still out there, I thought I'd share my notes and tips below as the whole process was quite interesting and perhaps it can at least save someone a bit of time. (Note: on the same site, I'll be doing the D5 to D6 upgrade in the next few weeks too, so I'll do a separate post for that here).
The first thing to always do, is to make backups repeatedly throughout the upgrade process. I had the following commands handy and ran them right before I did anything serious:
tar -czvf site-backup-`date '+%y%m%d-%H%M%S'`.tar.gz public_html mysqldump -u sitedb_primary -p sitedb_primary > \ `date '+%y%m%d-%H%M%S'`.sql
The other thing to do before you start, is to do all your upgrading on a staging or development version of the site first. This is because, theres a high chance you won't be able to do this whole process straight off the bat, and you probably don't want to leave your site in maitenance mode over night while you recover for another attempt.
The following guides/screencasts are what I followed to perform a successful upgrade, plus a few notes, I made that weren't covered:
1. Converting custom content types from Flexinode to CCK: http://docs.indymedia.be/node/1
- Make sure your flexinode fields all have unique names from one another. I had to rename a few of my flexinode body fields before flexiconvert would convert things successfully.
- Keep notes on all your original flexinode names and field names. This is so that when it comes to your themes you can easily update them to the new field names.
- When creating new content types, you must add the add/edit/delete privileges for each new content type before you can access this section.
2. Screencast for upgrading from D4.x to D5.x: http://drupal.org/videocasts/upgrading-to-5
- Disabling any custom theme or custom modules are some of the preparations recommended in the screencast. Before you do this though, make sure you don't have any php code used for block visibility that might use functions in these custom themes or modules. You can either update them with a function_exists(), or re-write them to work out the condition another way.
- Before running update.php, it might help to do run the following commands on the database "DELETE FROM `variable` WHERE `name` = 'cache_inc'; TRUNCATE TABLE `themonth_monthlydb`.`cache`;". I read somewhere that the D4 caching options were different in D5, and if you tried accessing the site after the upgrade without doing this, it would cause your site to die.
- If your going to leave your site in maintenance mode for an hour whilst you conduct the upgrade, and don't want the default Drupal Alien logo to show up, simply update the public_html/misc/maintenance.css body tag not to reference 'druplicon.png'. This might be particularly important if you have a popular site and don't want to scare people!
- For views, if you use the filter by 'Distinct', make sure its the first filter in your list, otherwise it doesn't seem to let you save it.
3. For converting your custom themes and modules to D5: http://drupal.org/node/64279
- For a custom nice_menu's css file, you can now specify the css filepath via Admin->Themes->Global Settings->Path to custom css file.
- Put all your custom modules in their own folder within public_html/sites/all/custom/
- Where possible try to keep your drupal install on the upgrade path by overriding things, or creating custom modules, rather then touching core or contributed php/theme code .
- When upgrading custom modules, if your in the process of doing things like updating modulename_settings - make sure you disable and then re-enable the module, otherwise, you'll get some whacky side effects like double admin menu items, etc.
If you are doing an upgrade, I wish you all the luck and patience in the world! And for those that believe in doing a site rebuild over the upgrade, I recommend you try the upgrade first and exhaust all possibilities before giving up, because either re-entering all your sites content, or hacking up a content copy script is more work then it seems.