Calling drupal_get_path() for a module on a site that has a local copy (e.g., "sites/yyy.com/modules/ecommerce/store") and also a copy in the the main directory (e..g, "modules/ecommerce/store") returns the path for the main copy instead of the local site copy.

Comments

ainigma32’s picture

Status: Active » Closed (works as designed)

I tested this in 5.7

  • Created directory sites/www.example.com/modules
  • Copied some module directory to this directory (in this case job_posting)
  • Created a page with php as input format and the following code in the body:
    echo drupal_get_path('module', 'job_posting');
    

The result was modules/job_posting as described in the original post.

Next I tried disabling and re-enabling the job_posting module but the effect was the same.

Finally I copied the settings.php file from the sites/default/ folder to the sites/www.example.com/ folder, and disabled and re-enabled the module.

Now the function returned the desired value sites/www.example.com/modules/job_posting

In this final setup I could change the output of the page by removing or adding the job_posting directory in the sites/www.example.com/modules/ directory.

The only way I could reproduce the original bug report was by removing the settings.php file from the sites/www.example.com/ directory.

This behaviour is caused by the conf_path function in bootstrap.inc. It determines if the sites directory contains a subdir that matches the hostname and if that site contains a file named settings.php. If it does that directory is returned, otherwise the sites/default directory is returned.

Since this behaviour is by design I'm setting this bug to by design

ainigma32’s picture

Status: Closed (works as designed) » Closed (fixed)

Housekeeping...