Is it safe to move my modules
on a production site?
That is, does Drupal automatically detect that the module is still there, but in a new path?
Drupal versions up to D6 kept module location in the system table, but starting from D7 there're multiple places where path is recorded (e.g. registry
and registry_file
tables) so just moving the folder and clearing cache will not do it, most probably will lead to significant problems.
A sequence of steps you can try:
Run following queries:
UPDATE system
SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/contrib');
UPDATE registry
SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/contrib');
UPDATE registry_file
SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/contrib')
Move folders
drush cc all
If you move a module Drupal will see that the old one is broken, and a new one exists. It will not assume the two are the same thing - simply moved.
irakli's answer worked well for me, but I wanted to add some additional complexity to the queries in case others find them useful.
Step 1 – Update all 'custom' modules if you're lucky enough to have them sharing a namespace:
UPDATE system SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/custom') WHERE name LIKE 'custom_namespace_%';
UPDATE registry SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/custom') WHERE name LIKE 'custom_namespace_%';
UPDATE registry_file SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/custom') WHERE filename LIKE '%custom_namespace_%';
Step 2 - Update all 'dev' modules:
UPDATE system SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/dev') WHERE name LIKE 'devel%';
UPDATE registry SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/dev') WHERE name LIKE 'devel%';
UPDATE registry_file SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/dev') WHERE filename LIKE '%devel%';
Step 3 - Update all 'contrib' modules:
UPDATE system SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/contrib');
UPDATE registry SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/contrib');
UPDATE registry_file SET filename = REPLACE(filename, 'sites/all/modules', 'sites/all/modules/contrib')
Then throw all of your modules into the appropriate sites/all/modules/contrib|custom|dev
folders, clear your cache, and you're good to go.
Drupal stores the file location in the system table, the info will be rebuilt when you clear the module cache, so if you move the stuff and clear the cache afterwards you should be fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With