Skip to content

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

Open
ousamabenyounes wants to merge 4 commits into
api-platform:mainfrom
ousamabenyounes:fix-8288-iri-helper-query-values
Open

fix(metadata): preserve bracketed indexes in query values#8409
ousamabenyounes wants to merge 4 commits into
api-platform:mainfrom
ousamabenyounes:fix-8288-iri-helper-query-values

Conversation

@ousamabenyounes

Copy link
Copy Markdown
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, after adding the regression test on upstream main:

....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 ....

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