Skip to content

fix(metadata): preserve bracketed indexes in query values - #8409

Open
ousamabenyounes wants to merge 1 commit into
api-platform:4.3from
ousamabenyounes:fix-8288-iri-helper-query-values
Open

fix(metadata): preserve bracketed indexes in query values#8409
ousamabenyounes wants to merge 1 commit into
api-platform:4.3from
ousamabenyounes:fix-8288-iri-helper-query-values

Conversation

@ousamabenyounes

@ousamabenyounes ousamabenyounes commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #8288
License MIT
Doc PR n/a

Summary

IriHelper::createIri() used to collapse encoded numeric brackets on the entire query string. That also rewrote bracketed indexes inside query values, for example x[0] became x[].

This keeps the existing list-key normalization, but applies it only to encoded query keys before joining each key=value pair back together.

Local review

Reviewed before opening this PR. No findings: the change is scoped to IriHelper, keeps the existing nested-array regression test, and adds a value-corruption regression test for the reported case.

Test verification (RED → GREEN)

RED, upstream 4.3 at 36d457f9 with only the new regression test applied:

....F.                                                              6 / 6 (100%)

1) ApiPlatform\Metadata\Tests\Util\IriHelperTest::testCreateIriPreservesBracketedNumericIndexesInQueryValues
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'/objects?v=x%5B0%5D&page=2'
+'/objects?v=x%5B%5D&page=2'

FAILURES!
Tests: 6, Assertions: 11, Failures: 1.

GREEN, with the fix:

......                                                              6 / 6 (100%)

OK (6 tests, 11 assertions)

Fix-reverted regression check:

....F.                                                              6 / 6 (100%)

ApiPlatform\Metadata\Tests\Util\IriHelperTest::testCreateIriPreservesBracketedNumericIndexesInQueryValues
Failed asserting that two strings are identical.
-'/objects?v=x%5B0%5D&page=2'
+'/objects?v=x%5B%5D&page=2'

FAILURES!
Tests: 6, Assertions: 11, Failures: 1.

Additional checks:

php vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --allow-unsupported-php-version=yes --dry-run --diff src/Metadata/Util/IriHelper.php src/Metadata/Tests/Util/IriHelperTest.php
Found 0 of 2 files that can be fixed

APP_DEBUG=1 php tests/Fixtures/app/console cache:warmup --env=test
php vendor/bin/phpstan analyse src/Metadata/Util/IriHelper.php src/Metadata/Tests/Util/IriHelperTest.php
[OK] No errors

All commands were run inside ephemeral Docker containers with docker run --rm -u "$(id -u):$(id -g)" -v "$PWD":/app -w /app composer:2 ....

@ousamabenyounes
ousamabenyounes force-pushed the fix-8288-iri-helper-query-values branch 2 times, most recently from a8715fc to f21e849 Compare August 20, 2026 15:12
@ousamabenyounes
ousamabenyounes changed the base branch from main to 4.3 August 20, 2026 15:12
@ousamabenyounes
ousamabenyounes force-pushed the fix-8288-iri-helper-query-values branch from f21e849 to 2230294 Compare August 22, 2026 23:43
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