From 63007742a71a26c8e64b67acdb45db0bdb9a0b75 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 3 Jul 2020 20:54:49 -0700 Subject: [PATCH] SetupController - Need better bootstrap to support localization While trying the setup UI on Backdrop, I found that changing the language led to a crash. The problem: it needed to load the `l10n` files, which led to more path resolution, which led to failures - because `civicrm.settings.php` hasn't been loaded. (It doesn't exist yet!) Fortunately, most of the needful information is available. The `Setup::init()` should have found the info and put it into `$model`. We just need to load the configuration into the right globals/constants. --- setup/src/Setup/UI/SetupController.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/setup/src/Setup/UI/SetupController.php b/setup/src/Setup/UI/SetupController.php index 444bea24d3..032582ff99 100644 --- a/setup/src/Setup/UI/SetupController.php +++ b/setup/src/Setup/UI/SetupController.php @@ -137,14 +137,27 @@ class SetupController implements SetupControllerInterface { * Partially bootstrap Civi services (such as localization). */ protected function boot($method, $fields) { + /** @var \Civi\Setup\Model $model */ $model = $this->setup->getModel(); define('CIVICRM_UF', $model->cms); + define('CIVICRM_TEMPLATE_COMPILEDIR', $model->templateCompilePath); + define('CIVICRM_UF_BASEURL', $model->cmsBaseUrl); + + global $civicrm_root; + $civicrm_root = $model->srcPath; // Set the Locale (required by CRM_Core_Config) global $tsLocale; $tsLocale = 'en_US'; + global $civicrm_paths; + foreach ($model->paths as $pathVar => $pathValues) { + foreach (['url', 'path'] as $aspectName => $aspectValue) { + $civicrm_paths[$pathVar][$aspectName] = $aspectValue; + } + } + // CRM-16801 This validates that lang is valid by looking in $langs. // NB: the variable is initial a $_REQUEST for the initial page reload, // then becomes a $_POST when the installation form is submitted. -- 2.25.1