From 180f343f3dd3d558742883ed61c1c0697b405145 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 7 Mar 2023 18:25:48 -0800 Subject: [PATCH 1/3] CmsBootstrap = Allow CIVICRM_BOOT=Auto://. --- src/CmsBootstrap.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CmsBootstrap.php b/src/CmsBootstrap.php index 371b6a0e..ccd0a7e5 100644 --- a/src/CmsBootstrap.php +++ b/src/CmsBootstrap.php @@ -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); } From 2d21f7e7fd0a5822310eb3cf383fdd12998d24d3 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 7 Mar 2023 18:28:20 -0800 Subject: [PATCH 2/3] Bootstrap - Allow CIVICRM_SETTINGS=Auto --- src/Bootstrap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bootstrap.php b/src/Bootstrap.php index 6243bf54..c249cf36 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -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. @@ -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'])) { From ffa554c9904990c5fa8399624183a3f6d395327b Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 7 Mar 2023 19:16:40 -0800 Subject: [PATCH 3/3] CmsBootstrap - Fix debug message This looks like a copy-paste error. A few lines above, it prints `Options: $this->options`. It makes more sense for the subsequent statement to print`CMS: $cms`. --- src/CmsBootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CmsBootstrap.php b/src/CmsBootstrap.php index ccd0a7e5..561f8527 100644 --- a/src/CmsBootstrap.php +++ b/src/CmsBootstrap.php @@ -130,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");