Skip to content

[ExpressionLanguage] Compile numbers with var_export in Compiler::repr for thread-safety#62350

Merged
nicolas-grekas merged 1 commit intosymfony:6.4from
yoeunes:fix-repr-thread-safety
Nov 12, 2025
Merged

[ExpressionLanguage] Compile numbers with var_export in Compiler::repr for thread-safety#62350
nicolas-grekas merged 1 commit intosymfony:6.4from
yoeunes:fix-repr-thread-safety

Conversation

@yoeunes
Copy link
Copy Markdown
Contributor

@yoeunes yoeunes commented Nov 9, 2025

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

This PR suggests replacing the setlocale() logic in Compiler::repr() with var_export() when compiling numbers.

The current use of setlocale() is not thread-safe and can cause race conditions in concurrent environments (e.g., Swoole, RoadRunner).

var_export() is locale-independent, thread-safe, and correctly handles all required float formats (3.3, 42.0, 1.0E-6, INF, NAN), as confirmed by the expanded test suite.

@nicolas-grekas
Copy link
Copy Markdown
Member

Thank you @yoeunes.

@nicolas-grekas nicolas-grekas merged commit e4c32e0 into symfony:6.4 Nov 12, 2025
10 of 11 checks passed
This was referenced Nov 13, 2025
This was referenced Dec 7, 2025
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.

4 participants