[Drupal] Migration step 5 - Update custom modules and website content to Drupal 7

By | 12th Jun 2015 | 2 min read

This article is prepared with the experience of migration on zyxware.com and I have tried my best to generalize it to migrate any Drupal 6 website to Drupal 7. The issues mentioned in these articles, although common in sites that have been migrated, need not be present in yours. Please learn from these articles and keep these articles as a safe practice, not as a guide to migration. Migration is different for every website!

Updating custom modules are pretty easy if you have written the code. The basic thing a person would do to make any module is to change the info file : version = 7.x-1.0 and core = 7.x . It is important to backup of your code and data before you enable the module as some of the code (functions, constants etc) which of Drupal 6 will throw errors in Drupal 7.

Some of the issues that I faced, which I think you would too are

  1. Block implementation is different in Drupal 7. hook_block() has been divided into hook_block_info() and hook_block_view(). View and info of blocks are separate unlike in Drupal 6.
  2. Cache constants; BLOCK_CACHE_GLOBAL and BLOCK_CACHE_PER_PAGE has been changed to DRUPAL_CACHE_GLOBAL and DRUPAL_CACHE_PER_PAGE respectively.
  3. drupal_urlencode() changed to drupal_encode_path().
  4. Block name should not be too long. Only 26 characters allowed (32 ideally but _block takes the 6 characters in database).

Drupal 6 content have to migrated too. This can be accomplished using content_migrate module. Enable the module and all other modules providing contents and fields like CCK. Go to your_site.com/admin/structure/content_migrate and you will see clearly what you can migrate. Check the boxes you wish to migrate and click "Migrate selected fields"! If you have a lot of content, this will probably take a while. After the content has been updated, you can click on the content and it will display it like in any Drupal site.

Since the content has been migrated and changed in the database, there is a good chance that views or blocks using this content will malfunction. The next step is to change that. You have to take every view/block and modify the fields to display the migrated fields where it is being displayed.

If you have used contexts, you'll have to create them again. Hopefully you haven't used too many. If you are migrating, make sure it's big change and you have a new theme and the works! This is going to be time consuming anyway so why not a make over! The only things remaining after this is to re-apply all your relevant patches and re-creating your feature.