Sometimes in Drupal, you need to rebuild the registry of themes and modules. This may be necessary when modules or themes are moved, renamed, etc. For example, a module was installed in the folder sites/all/modules
, but it must be moved to sites/all/contrib
without disabling or uninstalling. When activating the module, its location is recorded in the system tables system
, registry
, and registry_file
. These tables contain a list of available modules, their locations, and the paths of their files. When modules are moved, these tables must be updated accordingly.
To automate this process, use the Registry Rebuild module. In fact, this project is not a typical Drupal module but a script that automatically updates the registry. There are two ways to use this module.
Before performing any actions, make a backup of the database:
drush sql-dump > backup.sql
or
mysqldump -uuser -ppassword db_site_name > backup.sql
Using Registry Rebuild with Drush
- Download the module with
drush dl registry_rebuild
. After running this command, the module is placed in the Drush folder.drush/registry_rebuild
. You can also manually download and unpack the archive to your Drush root.
drush dl registry_rebuild
- Navigate to your site’s libraries folder (
sites/all
). For multisite installations, usesites/sitename
.
cd sites/all
- Run the command
drush rr
drush rr
Using Registry Rebuild without Drush
-
Create a folder
sites/all/modules/registry_rebuild
. For multisite installations, createsites/sitename/modules/registry_rebuild
. -
If your modules are located in a specific folder other than
sites/all/modules
, edit theDRUPAL_ROOT
variable in theregistry_rebuild.php
file. -
Copy the file
registry_rebuild.php
from the module archive into the folder created in step 1. -
Execute the file
registry_rebuild.php
via command line:
cd sites/all/modules/registry_rebuild
php registry_rebuild.php
or visit:
http://yoursite.com/sites/all/modules/registry_rebuild/registry_rebuild.php
You should see a message indicating a successful registry rebuild:
There were 510 files in the registry before and 510 files now. If you don't see any crazy fatal errors, your registry has been rebuilt.
You can verify the results and track changes in the tables: system
, registry
, and registry_file
.