dev/translation#39 - Fix `core:install --lang`. Realign boot code.
authorTim Otten <totten@civicrm.org>
Wed, 6 May 2020 22:02:09 +0000 (15:02 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 6 May 2020 22:19:30 +0000 (15:19 -0700)
commit1cc5f3932e19bf8cbebc147f1da37cbd13221b59
treebeac71d098c99c68b87761d7f50d0932956347d6
parent6e32198b6bcc4d93e62b6d033e356104da3e9b0f
dev/translation#39 - Fix `core:install --lang`. Realign boot code.

Overview
--------

Suppose you run a command like:

```
cv core:install --lang=fr_FR --cms-base-url=http://example.com/
```

This fixes that use-case by realigning some of the bootstrap steps under `setup/plugins/installDatabase/*`.

Before
------

* The above `core:install` command crashes because the `paths` service is unavailable.

* The `civi.setup.installDatabase` begins with these two steps:

    1. `InstallSchema.civi-setup.php` manipulates some global options (to make certain services work),
       and it also installs the schema, and it also reboots the `Container`.
    2. `BootstrapCivi.civi-setup.php` tries to boot again - e.g. it loads `civicrm.settings.php` and
       calls `CRM_Core_Config::singleton($loadFromDB=TRUE)`. But this is suspect because it
       neglects to set `$force=TRUE`.

After
-----

* The above `core:install` command runs.

* The `civi.setup.installDatabase` begins with these *three* steps:

    1. `Preboot.civi-setup.php` starts the system in a *partially booted* mode (ie with `$loadFromDB==FALSE`).
    2. `InstallSchema.civi-setup.php` just installs the schema.
    3. `BootstrapCivi.civi-setup.php` switches the system to a fully booted mode (ie with `$loadFromDB==TRUE`).

Technical details
-----------------

I tested this on a D7 build. My dev/test loop was basically these steps:

```
cv core:uninstall -f
cv core:install --lang fr_FR --cms-base-url='http://dmaster.bknix:8001' -vvv
echo 'select name, label, value from civicrm_option_value where name like "Meet%"' | cv sql
```

If the install succeeded, then the SQL command would display localized
labels for "Meeting" ("Reunion").
setup/plugins/installDatabase/BootstrapCivi.civi-setup.php
setup/plugins/installDatabase/InstallSchema.civi-setup.php
setup/plugins/installDatabase/Preboot.civi-setup.php [new file with mode: 0644]