drupal-registry-rebuild

In a previous blog post we discussed ways in which you can clear your Drupal website's cache when it is having hard crashes or the infamous "white screen of death" (WSOD). Being able to clear the Drupal cache is important because it can resolve a lot of various issues that may crop up, and is usually the first thing to do when something isn't working right. 

A specific case where clearing the cache may be helpful, but you might not be able to is if the Drupal registry (which records which PHP classes are being sourced from which files) may have outdated information preventing Drupal from bootstrapping even high enough to allow clearing of the cache.

You might see an error like the following:

PHP Fatal error:  Class 'EntityAPIControllerExportable' not found in ...sites/all/modules/rules/includes/rules.core.inc on line 11

In this case, rebuilding the registry is what needs to occur since manually clearing out database cache tables may not resolve the issue. One reason why this type thing might occur could be during a manual migration process and modules get moved around or removed. Fortunately, there is a very helpful Drush plugin called "Registry Rebuild" which can help resolve this problem. Keep in mind, that while you download this plugin, usually through Drush, it is not a Drupal module, it is a Drush plugin. This means you don't need to access your Drupal website to utilize this tool, you can just run it from the command line like any other Drush command.

The first step is to download the plugin into Drush, you can do this with the command "drush dl registry_rebuild". After that, you'll likely need to be able to clear Drush's internal cache with the command "drush cc drush". Now, you can run the registry rebuilding process for the broken Drupal website. The command you use will be "drush rr" and will need to be done within the Drupal file area on your host as you would expect, or using drush aliases.

After running the registry rebuild, if it proceeds normally you will see a response like the following:

The registry has been rebuilt via registry_rebuild (A).              [success]
All caches have been cleared with drush_registry_rebuild_cc_all.     [success]
The registry has been rebuilt via drush_registry_rebuild_cc_all (B). [success]
All caches have been cleared with drush_registry_rebuild_cc_all.     [success]
All registry rebuilds have been completed.

With luck, your Drupal website's registry issues will be resolved, with the registry table now reflecting the existing locations of files needed for required Drupal PHP classes. If this fails, an alternative may be to try and add back any modules or files in your Drupal website that might have been moved or removed. The last resort may be to restore to a backup, but the Drush Rebuild Registry plugin is great and should fix the problem for you.

Still having trouble getting your Drupal website back up and running?

We might be able to help you! Contact Us