Skip to content

Tags: symfony/flex

Tags

v2.11.0

Toggle v2.11.0's commit message
bug #1090 [DockerComposeConfigurator] Fix duplicate top-level key on …

…reconfigure (mistyfiky)

This PR was merged into the 2.x branch.

Discussion
----------

[DockerComposeConfigurator] Fix duplicate top-level key on reconfigure

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | —
| License       | MIT

## Problem

`composer recipes:install --reset --force` (or any re-invocation of `configure` against an already-marked `compose.yaml`) can produce a duplicate top-level key:

```yaml
###< some/recipe ###

volumes:
volumes:
###> other/recipe ###
  some-data:
###< other/recipe ###
```

`docker compose config` then rejects the file with `mapping key "volumes" already defined`.

Triggered when a recipe touches a non-last top-level section (e.g. `symfony/mailer` contributing only `services:` on a file that already has `volumes:`) and that recipe's markers are already present.

## Root cause

Two interacting bugs in `DockerComposeConfigurator::configureDockerCompose`. Either alone is harmless; the duplicate top-level key requires both.

**`$nodesLines` accounting.** The parser appends each line to `$nodesLines[$node]` *before* checking whether the line itself starts a new top-level key. So when the loop reaches `volumes:`, that header is recorded under the outgoing `services` node. When `services` is later updated and spliced back, the replacement carries a trailing `volumes:`; the original `volumes:` header sits one index past the splice range and survives — duplicate.

**Position-adjustment math.** After the in-place splice, `$startAt`/`$endAt` for later sections are adjusted by `-$length - 1` and `-$length` respectively. The correct shift is `-($length - 1)`.

**Why they mask each other.** Fix only the accounting bug and the next section's splice (with the off-by-two `startAt`) deletes that section's header. Fix only the math and the leftover key compounds — three consecutive `volumes:` lines. Together, the splice range matches what `$nodesLines[old node]` mirrors, and subsequent sections land at correct positions.

## Fix

1. On node transition, unset `$nodesLines[$node][$i]` (plus `[$i - 1]` if the previous line was blank) so recorded content matches the splice range `[startAt..endAt-1]`.
2. Use `$shift = $length - 1` for both `$startAt` and `$endAt` adjustments.

## Test

`testReconfigureDoesNotDuplicateLaterTopLevelKey` — fails on `2.x`, passes here.

Commits
-------

3446c0f [DockerComposeConfigurator] Fix duplicate top-level key on reconfigure

v2.10.0

Toggle v2.10.0's commit message
feature #1070 Fix dump-env command when .env files reference other en…

…v vars (nicolas-grekas)

This PR was merged into the 2.x branch.

Discussion
----------

Fix dump-env command when .env files reference other env vars

At the moment, running `composer dump-env` on a 7.4 project generates a broken `APP_SHARE_DIR`.
The reason is that since symfony/recipes#1465 we define that var as `"$APP_PROJECT_DIR/var/share"`
Yet, when the command runs, all env vars are emptied to make the result context-free.

This fixes it by hooking into calls to the `getenv()` function.

Commits
-------

ed41273 Fix dump-env command when .env files reference other env vars

v2.9.0

Toggle v2.9.0's commit message
minor #1068 Leverage COMPOSER_PREFER_DEV_OVER_PRERELEASE when possibl…

…e (nicolas-grekas)

This PR was merged into the 2.x branch.

Discussion
----------

Leverage COMPOSER_PREFER_DEV_OVER_PRERELEASE when possible

This leverages composer/composer#12585

The code added in #1066 remains as a fallback.

Commits
-------

cc37c66 Leverage COMPOSER_PREFER_DEV_OVER_PRERELEASE when possible

v2.8.2

Toggle v2.8.2's commit message

Verified

This tag was signed with the committer’s verified signature.
fabpot Fabien Potencier
Create tag 2.8.2

v2.8.1

Toggle v2.8.1's commit message

Verified

This tag was signed with the committer’s verified signature.
fabpot Fabien Potencier
Create tag 2.8.1

v2.8.0

Toggle v2.8.0's commit message

Verified

This tag was signed with the committer’s verified signature.
fabpot Fabien Potencier
Create tag 2.8.0

v2.7.1

Toggle v2.7.1's commit message
bug #1054 Don't remove still-referenced files when unconfiguring reci…

…pes (nicolas-grekas)

This PR was merged into the 2.x branch.

Discussion
----------

Don't remove still-referenced files when unconfiguring recipes

Instead of #706
Fixes broken logic added in #451, which didn't account for folders.
The new logic uses only the symfony.lock file and not the recipe anymore to decide which files to remove.

Commits
-------

6443e31 Don't remove still-referenced files when unconfiguring recipes

v2.7.0

Toggle v2.7.0's commit message
Fix flex upgrades

v2.6.0

Toggle v2.6.0's commit message

Verified

This tag was signed with the committer’s verified signature.
fabpot Fabien Potencier
Create tag 2.6.0

v2.5.1

Toggle v2.5.1's commit message

Verified

This tag was signed with the committer’s verified signature.
fabpot Fabien Potencier
Create tag 2.5.1