Skip to content
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

Allow explicit-automatic flags #150

Merged
merged 3 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
* type of CMS is being used.
* (Default: NULL)
* - env: string|NULL. The environment variable which may contain the path to
* civicrm.settings.php. Set NULL to disable.
* civicrm.settings.php (or the token "Auto"). Set NULL to disable environment-checking.
* (Default: CIVICRM_SETTINGS)
* - httpHost: string|NULL. For multisite, the HTTP hostname.
* - prefetch: bool. Whether to load various caches.
Expand Down Expand Up @@ -324,7 +324,7 @@ public function getCivicrmSettingsPhp($options) {
if (defined('CIVICRM_CONFDIR') && file_exists(CIVICRM_CONFDIR . '/civicrm.settings.php')) {
$settings = CIVICRM_CONFDIR . '/civicrm.settings.php';
}
elseif (!empty($options['env']) && getenv($options['env']) && file_exists(getenv($options['env']))) {
elseif (!empty($options['env']) && getenv($options['env']) && getenv($options['env']) !== 'Auto' && file_exists(getenv($options['env']))) {
$settings = getenv($options['env']);
}
elseif (!empty($options['settingsFile']) && file_exists($options['settingsFile'])) {
Expand Down
6 changes: 5 additions & 1 deletion src/CmsBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ public function bootCms() {
'path' => '/' . parse_url($cmsExpr, PHP_URL_HOST) . parse_url($cmsExpr, PHP_URL_PATH),
);
$cms['path'] = preg_replace(';^//+;', '/', $cms['path']);
if ($cms['type'] === 'Auto') {
$isAutoPath = (trim($cms['path'], '/') === '.');
$cms = $this->findCmsRoot($isAutoPath ? $this->getSearchDir() : $cms['path']);
}
if (!isset($this->options['user']) && parse_url($cmsExpr, PHP_URL_USER)) {
$this->options['user'] = parse_url($cmsExpr, PHP_URL_USER);
}
Expand All @@ -126,7 +130,7 @@ public function bootCms() {
$cms = $this->findCmsRoot($this->getSearchDir());
}

$this->writeln("CMS: " . json_encode($this->options, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), OutputInterface::VERBOSITY_DEBUG);
$this->writeln("CMS: " . json_encode($cms, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), OutputInterface::VERBOSITY_DEBUG);
if (empty($cms['path']) || empty($cms['type']) || !file_exists($cms['path'])) {
$cmsJson = json_encode($cms, JSON_UNESCAPED_SLASHES);
throw new \Exception("Failed to parse or find a CMS $cmsJson");
Expand Down