Skip to content

Create or extend Drupal settings in workspaces - #115

Open
csandanov wants to merge 1 commit into
masterfrom
fix/workspace-settings-include
Open

csandanov wants to merge 1 commit into
masterfrom
fix/workspace-settings-include

Conversation

@csandanov

Copy link
Copy Markdown
Member

Setting up a Drupal workspace failed when the project's settings.php was committed to Git: setup refused to add the Wodby include to a tracked file and asked the developer to add it by hand. Setup now does what a build does. It creates settings.php from default.settings.php when it's missing, and appends the Wodby include when the file doesn't have one. In a workspace, the include only loads Wodby's settings when that file exists, so the developer can commit the change and the file keeps working outside Wodby.

Changes

  • With WODBY_WORKSPACE=1, init_drupal appends this block instead of a plain include:

    // Generated by Wodby.
    $wodbyConfig = (getenv('CONF_DIR') ?: '/var/www/conf') . '/wodby.settings.php';
    if (is_file($wodbyConfig)) {
        include $wodbyConfig;
    }

    Multisite sites/sites.php gets the same block for wodby.sites.php. Files that already mention the Wodby file are left unchanged.

  • Setup still checks every path before changing anything. It never changes files outside the checkout, and it replaces the site's files directory with a link to the files volume only when Git ignores that directory and doesn't track it.

  • The path check now also works when the site directory doesn't exist yet.

  • Standard initialization output is byte-for-byte unchanged.

  • The README's workspace section describes the new behavior.

Validation

  • bash tests/workspace-checkout.sh on macOS, and inside wodby/drupal-php:8.5 with PHP 8.5 and Git 2.54. The test covers:
    • the include added to tracked settings as a 6-line change
    • PHP syntax, plus the include loading when Wodby's file exists and being skipped when it doesn't
    • a repeated run making no changes
    • already configured settings left unchanged
    • settings created from default.settings.php
    • multisite sites.php
    • settings linked outside the checkout being refused
    • tracked upload placeholders being kept, with settings unchanged when setup stops
  • The same test fails against the previous script.
  • Compared standard-mode output of the previous and new scripts on the same fixture: identical.

A new revision release is needed after merge so the Drupal services can use it.

Workspace setup refused to add the Wodby include to a tracked
settings.php, so preparation failed for projects that commit their
settings. It now works as in a build: it creates settings.php from
default.settings.php when it's missing and appends the include when
the file doesn't have one. In a workspace the include is skipped when
Wodby's settings file doesn't exist, so the file keeps working elsewhere
and the developer can commit it. Multisite sites.php gets the same
include.

Setup still never changes files outside the checkout, and it replaces
the files directory with a link only when Git ignores it and doesn't
track it. Standard initialization output is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant