-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cv with drupal7 multisite #54
Comments
Yeah, For a bit of background - there are two boot protocols in
What I like about
So... I've been angling to recommend
Heh, I hadn't read this issue and was playing with your PR and tried e0639c8. Great minds think alike? Or is that a different spin on similar idea? It allows:
I have to admit... the sites.php/aliasing stuff scares me. 🙃 Maybe it's just because I've never used them. Or maybe it's a nagging sensation of non-determinism. It might help if you could explain this bit more. (Or post code... whatever's easiest.) Tangentially: Do you think it's possible to take a CWD like |
Yeah, originally I was testing something similar to this (searching ancestor directories for the settings file). But in the time between opening issue #54 and submitting PR #57, I changed direction and decided to teach findDrupalDirs() about sites.php (this is what you see in 7f01345). Originally I wanted to avoid any unnecessary duplication of drupal logic in cv... but findDrupalDirs() is already copied directly from the D7 function for finding settings.php, so that didn't seem like much of an objection. But really I think either approach is fine.
There's really not much to it. sites.php is a mapping of site URLs to directory names. By default, if I have the site "foo.example.org" then drupal will expect to find the files for that site in the "sites/foo.example.org" directory. But if I want to name the directory "sites/myFolder", then in sites.php I would put: $sites = array (
'foo.example.org' => 'myFolder',
); That's it -- it contains the $sites array, nothing else. It just allows site admins more control over how the site is structured. So technically, the current code in findDrupalDirs() is incomplete if it doesn't account for sites.php (in fact, it's likely that whoever wrote findDrupalDirs stripped out the sites.php parts when they pulled the logic from the drupal function).
Yes, I think it should be possible, and in fact I was initially looking into doing something like that -- if CWD is /var/www/html/sites/example.com/files, then cv should be able to find the settings file without any hints from --hostname etc. What stopped me IIRC was that it seemed like there would be some sequence-of-events issues -- i.e. making sure that you've always figured out the CMS info before you look for civicrm.settings.php. Given that the CMS and Civi can currently boot in either order, this looked like it might require more elaborate surgery in cv's boot process, probably better done by someone who's not a cv neophyte like me. So I punted on that approach. I think this is exactly what you're getting at when you mention always booting the CMS first, and other chicken-or-the-egg issues? Perhaps I should revisit this -- do you think it would be simpler than I'm picturing? On a somewhat related note, I've recently been testing the upgrade:get and upgrade:dl commands (after uncommenting them), and they work as expected, but they do need some minor tweaks for multisite. Basically, the --hostname param (and probably others like --level I think?) need to be passed down to sub-commands (e.g. when upgrade:dl calls vars:show), so that drupal can boot. Would you like to address this as part of this PR, or handle it when the upgrade commands eventually get enabled? I have some test code here: c4c0e54 (might have merge conflicts with your multisite branch but I can rebase if it would help). |
I suspect it would be cleanest to switch those commands from
Yeah, that is a curveball. It helps me to think of those as two entirely separate protocols and deal with them at different times. So do some work on the Civi-first protocol (
OK, seeing it in that format makes it easier to recognize the ambiguity, e.g. this looks to be valid: $sites = array (
'foo.example.org' => 'myFolder',
'bar.example.org' => 'myFolder',
); If you're in the folder The rub is that these rules are complicated. The path
I think there are two basic options here:
|
I've been playing around with cv in a drupal7 multisite setup, and I've run into two related problems:
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.)
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
The text was updated successfully, but these errors were encountered: