Drupal 7 Registry Issues After Drupal Core update
Share with Others
I recently was helping a new Drupal developer with some issues after they attempted a Drupal update that really messed up their Drupal website. They were getting a bunch of Fatal errors that were causing the site to be completely broken. This user was on a Windows system running a Drupal 7 development site on their localhost. Here are the steps I tried and how I fixed the problem.
Download a new Drupal 7 core
The first thing I tried was to download a new Drupal 7 core, migrate all the modules and themes from the sites/all folder, migrate the files from the sites/upgrade.codekarate.com/files folder, and copy the settings file. My thought here is that somehow the Drupal core files were corrupted (I think this developer hit yes when Windows asked if it should attempt to merge files... turns out this will not work).
After navigating to the new Drupal site, I ran into the same fatal error issues. I tried truncating all the cache tables in the database thinking that might help, but still no luck.
After some additional investigation, I soon learned that this PHP fatal error was being caused by a Drupal 7 registry issue.
Examining the Drupal registry table
Next I took a look at the Drupal registry table and noticed that many things seemed wrong. A lot of the file paths were incorrect due to the strange way the files attempted to be merged. I did some more digging and found the Drupal Registry Rebuild drush command.
Using Registry Rebuild
Outside of this Drupal root, I used drush to download registry rebuild using
drush dl registry_rebuild
I then changed the directory to the sites/all directory of the broken Drupal website and ran the following command to rebuild the registry.
Everything went through fine and I was thinking I just made a miracle happen. Turns out I was wrong again. Now fatal errors were still showing but they mentioned missing classes (I don't remember the exact error messages).
My Solution: Replace the entire registry table from another working Drupal site
After additional research I noticed the registry rebuild command seemed to create a much smaller registry. I decided to try a drastic measure. I completely truncated the registry table on a broken site. Used PHPMyAdmin on the Windows system to dump a copy from another functioning Drupal 7 websites, then imported that registry into the broken Drupal 7 website.
I then used Drush to clear the caches, and amazingly the site worked!!!
I am not exactly sure why the Registry Rebuild Drush command did not work correctly, but this solution worked for me and I am guessing there are others out there who will run into similar issues when trying to update Drupal core for the first time.
Because of these issues, I highly recommend using Drush or Aegir to handle all your updates/migrations.