Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I foolishly did this, when updating a module:

# cd /var/www/drupal7/modules
# wget <MODULE_URL> -O - | tar xfvz -

After refreshing the module list, I still get the old module's version because, surprise, it found the MODULE.old subdirectory first. Or last. Or whatever.

I can of course do

# rm -r MODULE.old
# ln -s MODULE MODULE.old

but that's a temporary measure at best.

How do I remove these MODULE.old directories? drush cc also tries to access them and won't run if they're not there!

share|improve this question
It's just my guess, but try to 1) disable said module 2) remove .old directory 3) clear all caches 4) enable module. If this or similar procedure will work, feel free to post it as self-answer, or to comment @ me and tell me to do it ;) –  Mołot Feb 13 at 10:44
Wouldn't disabling these modules drop the database tables they created? –  Matthias Urlichs Feb 13 at 10:46
False, uninstalling them clears database tables, disabling does not. –  Mołot Feb 13 at 10:47
Ah, OK, will try then. –  Matthias Urlichs Feb 13 at 10:47
add comment

2 Answers

The best way to do this is to disable the module, remove the '.old' folder and then re-enable the module. Unless disabling the module is destructive, this is the course of action I would recommend.

Otherwise you need to call registry_rebuild, though as you've realised you can't do this from a module because your site won't bootstrap. There is drush command made just for this case which you can find at https://drupal.org/project/registry_rebuild

If none of this works, you will need to manually edit the database ; you will need to manually edit the 'system' table and clear the system cache. Not recomended.

Whichever option you go for, make a backup of your database first!

share|improve this answer
+1 for drush rr very useful for these situations –  Beebee Feb 13 at 10:54
… except when it doesn't work: drush rr PHP Fatal error: Call to undefined function module_load_include() in /srv/www/drupal7/modules/entity/entity.module on line 8 –  Matthias Urlichs Feb 13 at 11:28
add comment

Since drush rr does not work in my setup for whatever reason, I ended up hacking a temporary path cleanup function to bootstrap.inc.

--- /usr/share/drupal7/includes/bootstrap.inc       2014-02-13 11:26:07.710709587 +0000
+++ /tmp/boots      2014-02-13 11:26:04.722628976 +0000
@@ -3100,6 +3100,21 @@
  *   TRUE if the resource was found, FALSE if not.
  *   NULL if either of the REGISTRY_* constants is passed in as $type.
+function _fixpath($fn) {
+  $last = "";
+  $pieces = explode("/", $fn);
+  $p = array();
+  foreach ($pieces as $pp) {
+    if (fnmatch("*.old",$pp)) { $pp = substr($pp,0,-4); }
+    if ($pp == "OLD") { continue; }
+    if ($last == $pp) { continue; }
+    $last = $pp;
+    $p[] = $pp;
+  }
+  return implode("/",$p);
 function _registry_check_code($type, $name = NULL) {
   static $lookup_cache, $cache_update_needed;

@@ -3136,7 +3152,7 @@
   $cache_key = $type[0] . $name;
   if (isset($lookup_cache[$cache_key])) {
     if ($lookup_cache[$cache_key]) {
-      require_once DRUPAL_ROOT . '/' . $lookup_cache[$cache_key];
+      require_once DRUPAL_ROOT . '/' . _fixpath($lookup_cache[$cache_key]);
     return (bool) $lookup_cache[$cache_key];
@@ -3158,7 +3174,7 @@
   $lookup_cache[$cache_key] = $file;

   if ($file) {
-    require_once DRUPAL_ROOT . '/' . $file;
+    require_once DRUPAL_ROOT . '/' . _fixpath($file);
     return TRUE;
   else {

After running drush cc I could remove that hack.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.