Resolving of Symlinks when installing modules?

Events happening in the community are now at Drupal community events on www.drupal.org.
IncrediblyKenzi's picture

I've got an interesting case here.

I've got a multisite installation that we're creating on Drupal6, for which we have the following structure:

  • sites/all -- shared modules
  • sites/mysite1 -- specific modules for this site
  • sites/example.com -- symlink to mysite1
  • sites/mydev.com -- symlink to mysite1

(names changed to protect the innocent)

Assume that example.com is the production domain, which we have no control over. mydev.com is our devleopment environment.

The problem is when we enable modules on the mydev.com site, the path it saves in the system table for filename is sites/mydev.com/modules/{modulename}/{modulename}.info, rather than resolving to its parent symlink, which should be sites/mysite1/modules/{modulename}/{modulename}.info

What happens is when we try to port this to a local environment or to production, the paths on modules are incorrect and the site breaks.

This seems like a bug that could be solved by wrapping $file->filename in module.inc with realpath().

Does this strike anyone as feasible?

I haven't checked the module subsystem on D7 yet. If it's the same I can file a bug and create a patch.

Comments

Confirmed on D7 as

IncrediblyKenzi's picture

Confirmed on D7 as well..

Link to patch is here:
http://drupal.org/node/664032#comment-2583940

More workarounds

srhaber's picture

Hey Aaron!

I've experienced this too using a similar symlink mapping strategy.

The realpath() lookup is a good workaround, but it's dependent on mysite1 having the same physical path across all environments and this might not always be the case.

Here are some other solutions:

  • If possible, have the production environment match the same symlink setup as the dev environment.

  • After porting a site, run this SQL command (mysql):

    UPDATE system SET filename=REPLACE(filename, 'mydev.com', 'mysite1')
  • Immediately visit the admin/build/modules page to rebuild the module info cache.

  • Use a simple Drush script to rebuild the module cache.

      if (drush_drupal_major_version() < 7) {
        $ret = module_rebuild_cache();
      }
      else {
        $ret = system_rebuild_module_data();
      }
      cache_clear_all();

If a newly ported site appears broken, it can generally be resolved by rebuilding the module cache. Same applies to the theme cache. As long as the path exists, whether physical or logical, it'll be fine.

Multisite

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: