Skip to content

fix(drupal-contrib): fix drupal_version option order to match drupal-core, fixes #132#144

Merged
rfay merged 9 commits into
mainfrom
20260510_drupal11-12-contrib
May 10, 2026
Merged

fix(drupal-contrib): fix drupal_version option order to match drupal-core, fixes #132#144
rfay merged 9 commits into
mainfrom
20260510_drupal11-12-contrib

Conversation

@rfay
Copy link
Copy Markdown
Member

@rfay rfay commented May 10, 2026

Summary

Two fixes for issue #132 where selecting Drupal 12.x installed Drupal 11.x instead:

Fix 1 — parameter option order: Reorders the `drupal_version` options in `drupal-contrib` from `11 → 12 → 10` to `12 → 11 → 10`, matching `drupal-core`. Coder's workspace wizard carries the selected option by index across steps, so the mismatched order caused index 0 ("12" in drupal-core) to resolve to index 0 ("11" in drupal-contrib). Default remains `11` (current stable), appropriate for contrib work.

Fix 2 — DRUPAL_CORE env var: `ddev-drupal-contrib`'s `expand-composer-json` / `ddev poser` reads a `DRUPAL_CORE` environment variable and defaults to `^11` if unset. The startup script was not setting it, so `ddev poser` always installed Drupal 11 regardless of the parameter. Now calls `ddev dotenv set .ddev/.env.web --drupal-core "^$DRUPAL_VERSION"` after the addon is installed and before `ddev start`, so the container environment carries the correct constraint.

Manual testing

Push the template as an inactive version (no image build needed — config-only change):

make push-template-drupal-contrib ACTIVATE=false

Note the new version name from the output (e.g. `sore_hughes16`), then create a test workspace using https://www.drupal.org/project/skipto/issues/3566898, which has both an issue fork and branch and supports Drupal 12:

coder create --template drupal-contrib --template-version sore_hughes16 test-issue-132fix   --parameter "project_name=skipto"   --parameter "project_type=module"   --parameter "drupal_version=12"   --parameter "issue_fork=3566898"   --parameter "issue_branch=3566898-add-the-ability"   --parameter "install_profile=minimal"   --yes

Once the workspace finishes starting, verify the installed Drupal version:

ssh test-issue-132fix.coder "grep -E 'DRUPAL_CORE|drupalConstraint' /tmp/drupal-setup.log"
# Expected: DRUPAL_CORE set to ^12, drupalConstraint=^12

ssh test-issue-132fix.coder "ddev drush status | grep 'Drupal version'"
# Expected: Drupal version : 12.x.x

Clean up when done:

coder delete test-issue-132fix --yes

To promote the version once verified:

coder templates versions promote drupal-contrib --template-version sore_hughes16

🤖 Generated with Claude Code

@rfay rfay changed the title fix(drupal-contrib): fix drupal_version option order to match drupal-core fix(drupal-contrib): fix drupal_version option order to match drupal-core, fixes #132 May 10, 2026
@rfay
Copy link
Copy Markdown
Member Author

rfay commented May 10, 2026

In the PR, for manual testing, suggest this Drupal issue (from the related issue here): https://www.drupal.org/project/skipto/issues/3566898

That has issue fork and branch

rfay and others added 9 commits May 10, 2026 15:34
…th drupal-core

Options were ordered 11, 12, 10 (default 11) while drupal-core had 12, 11, 10
(default 12). The mismatch caused Coder workspace wizard to install the wrong
Drupal version when selecting 12.x. Fixes #132.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ble)

12.x is the main branch, not yet stable. Contrib issue work typically targets
the current stable release (11.x), unlike drupal-core where main-branch work
is the norm.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ser respects selected version

ddev-drupal-contrib's expand-composer-json defaults DRUPAL_CORE to ^11 if the
env var is unset. The startup script was not setting it, so ddev poser always
installed Drupal 11 regardless of the drupal_version parameter. Use
'ddev dotenv set .ddev/.env.web --drupal-core' after addon install but before
ddev start so the container environment carries the right constraint.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mposer.json

composer require drush/drush without a version lets Composer auto-determine
a constraint (e.g. ^13.7) and write it into the module's composer.json.
expand-composer-json then copies that pinned constraint into composer.contrib.json.
Drush 13.x requires symfony/yaml ^6||^7, which conflicts with Drupal 12's
requirement of symfony/yaml ~v8. Using drush/drush:* overrides any existing
pinned constraint (including one the module already carries) so Composer can
resolve Drush 14.x-dev which supports Symfony 8.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
No Drupal 12 case existed, so the drush/symfony conflict would have passed
undetected. skipto targets Drupal 12 in its own composer.json and is a
suitable CI canary for D12 contrib compatibility.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Write .git/info/exclude so workspace-generated untracked files (.ddev/, web/,
vendor/, scaffold files, recipes/) don't appear in git status. This file is
never committed and doesn't touch the module's own .gitignore.

Restore composer.json after ddev poser succeeds — drush is now in vendor/ so
the require entry is no longer needed and shouldn't show as a local modification.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… files

Excluding web/, vendor/, .editorconfig etc. is the module's own .gitignore
concern. ddev-drupal-contrib explicitly recommends committing .ddev/ changes,
so blanket-excluding .ddev/ conflicts with that philosophy. Only hide the
three files that coder-ddev itself generates: .env.web, config.coder.yaml,
docker-compose.coder-describe.yaml, and config.local.yaml (themes only).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mposer.json

git checkout composer.json removed drush from the file, causing ddev restart
to rebuild vendor/ without drush and breaking drush en. Use
git update-index --skip-worktree instead: the file content (and drush entry)
stays intact so ddev never reinstalls, but git status hides the modification.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…poser require

ddev-drupal-contrib README explicitly says to manually add dev dependencies
to require-dev rather than using the composer require command.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rfay rfay force-pushed the 20260510_drupal11-12-contrib branch from 5177159 to da7ed06 Compare May 10, 2026 21:34
@rfay rfay merged commit 2e81e9a into main May 10, 2026
21 checks passed
@rfay rfay deleted the 20260510_drupal11-12-contrib branch May 10, 2026 22:14
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