Drupal 7 shipped this time last year, introducing many API changes, new features and goodies for everyone. One of the more hidden features though is the new Code Registry engine, which scans Drupal and caches classes and their files to improve system performance by only loading the code it needs per page request.
However, when you are updating code, removing modules, or doing other general site maintenance, you might run into an error like this that scares the bejeesus out of you:
Fatal error: Class ‘EntityFieldHandlerHelper’ not found in ~/public_html/sites/all/modules/entity/views/entity.views.inc on line 134
Boom. Nothing but you, a white screen, a fatal PHP error and probably lots of “WTF??’s” dancing around your head and no clear way to recover and get the site back up.
Whats happening here is you have moved or updated code that changes either the location of a class definition or the file that contained it. Since it is no longer where Drupal’s code registry expects it to be, we need to clear the registry out and rebuild it. There is an internal function to do this, but there is a quicker way to get up and going again.
Any veteran user of Drupal at this point should be familiar with Drush, the excellent shell tool for administering Drupal and using it at every turn. While your first thought may be to call this:
1
| |
You may notice that the error will persist beyond this. That’s because (at the time of this writing) the Drush action that clears Drupal cache does not rebuild code registry. It is important to note that this function and the ‘clear cache’ button in Drupal will not rebuild the registry. We need to grab and add an additional command into our Drush arsenal, “Registry Rebuild”.
The easiest method to install this add-on is right in the terminal:
1 2 3 4 | |
Now, you should be good to go. Become a Drush warrior!