civicrm.config.php cannot find settings when multisite is enabled
Created by: jonhalle
I was having a problem that extern.php could not locate civicrm.config.php
Looking at civicrm.config.php.backdrop it contains a mechanism to find civicrm.settings.php in a multisite setup.
// Alias could be defined in sites/sites.php
if (file_exists($confdir . "/sites.php")) {
include $confdir . "/sites.php";
}
but it has a minor error - as the comment says, the sites.php is located in the sites subdirectory so looking for it in the $confdir does not work.
A really ugly workaround is to create a couple of symlinks from the backdrop root directory to the sites subdirectory
ln -s sites/sites.php sites.php
ln -s sites/my-site-name my-site-name
Alternatively the code ought to say:
// Alias could be defined in sites/sites.php
if (file_exists($confdir . "sites/sites.php")) {
include $confdir . "sites/sites.php";
}
This also requires a change later in the file to again explicitly add the 'sites' dir with a
if (isset($sites[$dir]) && file_exists($confdir.'sites/'."{$sites[$dir]}/civicrm.settings.php")) {
$conf = $confdir.'sites/'."{$sites[$dir]}";
return $conf;
}
Looks like the D7 code also needs a change here as I think Drupal 7 and Backdrop define sites in the same place.
The code in question goes back to 2015:
https://github.com/civicrm/civicrm-drupal/pull/327/files#diff-2052e8c39d1751b7d68bc909f7962cb7
Presumably it worked then on Drupal - possibly only on sites with symlinks in place as described above. Very possibly not many people use Backdrop or Drupal in multisite mode with CiviCRM, which might be why this has not been an issue for others.