Skip to content

Conversation

@soyuka
Copy link
Contributor

@soyuka soyuka commented Sep 29, 2025

Q A
Branch? 7.4
Bug fix? yes
New feature? no
Deprecations? no
Issues n/a
License MIT

This fixes a BC break introduced in #60228.

At https://github.com/symfony/symfony/pull/60228/files#diff-b031dbb2186367839adfe20696612866da91513dd315f00ad6df23b5d38fca74R381 the condition change breaks encoding of an empty array:

-     if (ctype_digit(implode('', array_keys($data)))) {
+    if (!$preserveNumericKeys && null === array_find_key($data, static fn ($v, $k) => is_string($k))) {

Indeed, array_find_key on an empty array correctly finds no string keys and returns null, making the condition true. The previous version using ctype_digit was false.

@soyuka soyuka requested a review from dunglas as a code owner September 29, 2025 11:59
@carsonbot carsonbot added this to the 7.4 milestone Sep 29, 2025
@soyuka soyuka force-pushed the xml-encoder-preserve-key-breaks branch from 9b30112 to f7be1cc Compare September 29, 2025 12:01
@symfony symfony deleted a comment from carsonbot Sep 29, 2025
@soyuka soyuka force-pushed the xml-encoder-preserve-key-breaks branch from f7be1cc to be51e2c Compare September 29, 2025 12:04
@nicolas-grekas
Copy link
Member

Thank you @soyuka.

@nicolas-grekas nicolas-grekas merged commit 2284ac7 into symfony:7.4 Sep 29, 2025
9 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants