Problem/Motivation

I had a problem with config_installer trying to modify settings.php when I installed site on Acquia hosting (read-only files system).

After I committed settings.php with

$settings['install_profile'] = 'config_installer';

profile still tried to rewrite this config with the exactly same value.

See http://cgit.drupalcode.org/config_installer/tree/src/Form/SiteConfigureF.... I am not sure why it is needed. Maybe we can safely remove it as standard installation step install_write_profile takes care of this.

Proposed resolution

Ideally the config_installer would not be a profile because the install profile should be determined via configuration and can influence what modules are discovered. The switching of profiles during the installation is extremely flaky and this is why this functionality belongs in core. However given #2156401: Write install_profile value to configuration and only to settings.php if it is writeable we can limit the cases where we have to write to settings.php.

The fix cannot be tested via an automated test cause file perms. The patch must be manually tested.

Remaining tasks

User interface changes

The config sync directory setting is disable if it can not be set.

API changes

None

Data model changes

None

Comments

ygerasimov created an issue. See original summary.

ygerasimov’s picture

Status: Active » Needs review
StatusFileSize
new1.18 KB

In attached patch I simply removed the code adding changes to settings.php

heddn’s picture

alexpott’s picture

Status: Needs review » Needs work

In 8.3.x we no longer need to write to settings.php for the install profile. So this is fixable - see #2855953: Incompatible with 8.3.x before that this one is a little tricky to fix. We definitely need to ensure that the install profile in the incoming config is used at some point and we need to maintain the fact we're using the config_installer during the install. This is precisely what makes this profile so tricky.

alexpott’s picture

Title: Modifying settings.php on read-only Acquia hosting » Trying to modifying settings.php when it is read-only
Issue summary: View changes
Status: Needs work » Needs review
Related issues: +#2156401: Write install_profile value to configuration and only to settings.php if it is writeable
StatusFileSize
new2.43 KB

Here's a patch that allows settings.php to be read-only and only writes if truly necessary - this might fix a few situations pre 8.3.0 and it will fix all situation post 8.3.0 because of #2156401: Write install_profile value to configuration and only to settings.php if it is writeable

This is can't be tested with an automated test because unfortunately you can't really make the settings.php read-only in the tests it'll just do weird things.

Tests with the patch

Drupal test run
---------------

Tests to be run:
  - Drupal\config_installer\Tests\ConfigInstallerEnSecondTest
  - Drupal\config_installer\Tests\ConfigInstallerFrDirectorySyncTest
  - Drupal\config_installer\Tests\ConfigInstallerFrTarballTest
  - Drupal\config_installer\Tests\ConfigInstallerNoDependenciesProfile
  - Drupal\config_installer\Tests\ConfigInstallerSyncTest
  - Drupal\config_installer\Tests\ConfigInstallerTarballTest
  - Drupal\config_installer\Tests\UninstalledProfileModulesTest

Test run started:
  Monday, February 27, 2017 - 14:48

Test summary
------------

Drupal\config_installer\Tests\ConfigInstallerEnSecondTest     36 passes
Drupal\config_installer\Tests\ConfigInstallerFrDirectorySync  32 passes
Drupal\config_installer\Tests\ConfigInstallerFrTarballTest    35 passes
Drupal\config_installer\Tests\ConfigInstallerNoDependenciesP  28 passes
Drupal\config_installer\Tests\ConfigInstallerSyncTest         35 passes
Drupal\config_installer\Tests\ConfigInstallerTarballTest      39 passes
Drupal\config_installer\Tests\UninstalledProfileModulesTest   45 passes

Test run duration: 1 min 49 sec

There's no before and after because there is no test added by the patch. Also the tests where performed with 8.3.x as the 8.2.x path has not really changed. (I did you tests with 8.2.x and they were similarly all green - but would be just duplicating by copying and pasting that here.

xano’s picture

We've been successfully using the patch in #5 for two months now. Thanks! :)

(I don't have the time to be more useful and research if this is indeed the right solution, so unfortunately I cannot RTBC)

drupalninja99’s picture

On Pantheon I still get this:

This environment is in read-only Git mode. If you want to make changes to the codebase of this site (e.g. updating modules or plugins), you will need to toggle into read/write SFTP mode first.
You are about to DROP all tables in your 'pantheon' database. Do you want to continue? (y/n): y
Starting Drupal installation. This takes a while. Consider using the        [ok]
--notify global option.
Drupal\Core\Installer\Exception\InstallProfileMismatchException: The     [error]
selected profile <em class="placeholder">config_installer</em> does
not match the install_profile setting, which is <em
class="placeholder">profile name</em>. Cannot write updated setting to <em
class="placeholder">sites/default/settings.php</em>. in
liam mcdermott’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #5 worked excellently for us (we were having this problem with a site hosted on Platform.sh). The fix in the patch is well documented and it works, so am marking RTBC.

Regarding #7 the patch isn't meant to handle the case where the installed profile name is different than what's in settings.php, so this seems like a different issue.

joelstein’s picture

Patch in #5 worked for me, too. Thanks!

xano’s picture

Just want to pop in and confirm that after six months this patch is still doing well :)

alexpott’s picture

Crediting @Xano and @Liam McDermott for testing this patch in production and reporting success.

  • alexpott committed 86d2447 on 8.x-1.x
    Issue #2819385 by ygerasimov, alexpott, Xano, Liam McDermott: Trying to...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed
schnitzel’s picture

epic, thanks everybody that worked on that! Just tested that on the amazee.io hosting system that is read only and it works perfectly.

Can we get a release? :)

alexpott’s picture

@Schnitzel done

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.