civicrm / civicrm/cv

cv with drupal7 multisite

Open
#54 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
45
Forks
36
Avg merge
17h 54m
Merged PRs (30d)
3

Description

I've been playing around with cv in a drupal7 multisite setup, and I've run into two related problems:

1) The only bootstrap levels that work are classloader/settings; booting drupal will fail (at the http redirect in includes/install.inc:install_goto()). It works if I set $_SERVER[HTTP_HOST] = 'mysite.org' in Bootstrap.php+CmsBootstrap.php, before they simulate the web environment. (Is there a way to detect this kind of redirect failure? Right now it fails silently which is not ideal.)

2) cv's search for civicrm.settings.php does not find anything. I'd expect cv to find the settings file if I first cd into [cmsroot]/sites/mysite (or one of its children), similarly to how it works with drush. But findDrupalDirs() tries to guess folder names under sites/ based on $options['httpHost'] (pulled from $_SERVER[HTTP_HOST]) which is empty. So it ends up checking just [cmsroot]/sites/ and [cmsroot]/sites/default.

So it seems like cv needs a "--hostname" option, that would be used to set $_SERVER[HTTP_HOST]. This would be analogous to drush's --uri option, and would address both problems.

I also wonder if the settings file search procedure should be changed to make findCivicrmSettingsPhp() also check all ancestor directories (starting with cwd) for the settings file. This will help with drupal's sites.php aliasing, where the site directory name and host name might be different.

Does something along these lines seem reasonable? You can see a preliminary version of it here: https://github.com/pcurrier/cv/commits/master

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with Bootstrap.php, CmsBootstrap.php, findDrupalDirs(), and findCivicrmSettingsPhp(), then review the Drupal 7 multisite bootstrap and settings lookup paths described in the issue. Check the referenced includes/install.inc redirect behavior and the preliminary commits. Done means the proposed hostname handling and ancestor-directory lookup work for multisite aliases without breaking existing bootstrap levels.

Written by the indexing model from the issue text.

Assessment

Tech stack
drupal, php
Domain
backend, cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.