davidosomething
davidosomething

Reputation: 3437

Drupal - moving module folder

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?

Upvotes: 14

Views: 8004

Answers (10)

irakli
irakli

Reputation: 869

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:

  1. Backup your database
  2. Check-in your code into version control
  3. 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')
    
  4. Move folders

  5. Run: drush cc all

Upvotes: 21

user2658547
user2658547

Reputation: 11

Actually you only need to do the update on the system table and then do the following:

drush rr 

and maybe..

drush cc all

drush rr

Upvotes: 1

drupalastic
drupalastic

Reputation: 11

dont forget to use this module after changing the modules folder :

https://drupal.org/project/registry_rebuild

Upvotes: 1

jorisx
jorisx

Reputation: 11

use http://drupal.org/project/registry_rebuild "Registry Rebuild will also rebuild the system table to get the modules in the right place so you can bootstrap."

  • backup the db
  • uploaded the 'module'
  • moved all the modules
  • run the script sites/all/modules/registry_rebuild/registry_rebuild.php
  • reload the site
  • if you get an error clear the browser cache and all is working again

Upvotes: 1

Sumeet Pareek
Sumeet Pareek

Reputation: 2819

If you are on D7, then this drupal documentation page is the best way to go ahead with moving modules around - How to move modules and themes

Upvotes: 2

Charlie Schliesser
Charlie Schliesser

Reputation: 8246

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.

Upvotes: 3

donquixote
donquixote

Reputation: 5491

You can move most of the modules safely, if you clear the cache afterwards (drush cc all).

However, some modules, especially ctools, store file path information in places other than the system table or caches. You may have to leave those modules in their original location, but you can still move everything else.

Upvotes: 0

trimax
trimax

Reputation: 11

It's good to have /contrib and /custom subfolder for the modules. For D7, specially if you use entity, you should disable the modules, move them and then re-enable. It works.

The alternative, move the modules to the subfolders and clear cache, sometimes doesn't work and may generate WSOD.

Upvotes: 1

googletorp
googletorp

Reputation: 33285

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.

Upvotes: 2

McAden
McAden

Reputation: 13970

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.

Upvotes: 3

Related Questions