-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][Uid] UuidV1 case depends on uuid
installed or not
#57878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Given that the predefined routing requirements for uuids enforce lowercase, I think we should enforce the usage of lowercase even when using the PHP extension (if we want to optimize things when using the polyfill which already guarantees lowercase, we might want to use |
And the polyfill should behave exactly like the extension. |
@stof @nicolas-grekas thanks for the quick answers! So to confirm, next actions would be:
@stof there is alreay this check in the bootstrap.php file of the polyfill Do you suggest we add it somewhere in the component code ? |
Is Looks to me it's always slower than |
strtolower has been optimized in recent versions of PHP indeed |
I recall that I've had that problem with the different casing on different machines a couple of years ago. I might be utterly mistaken, but I think I came to the conclusion that the behavior of the extension with regards to UUID casing depended on the libraries the extension was compiled against. |
So... do you think we need to change the polyfill ? |
No because the polyfill already reflects a correct behavior. |
This PR was submitted for the 7.2 branch but it was merged into the 5.4 branch instead. Discussion ---------- [Uid] Ensure UuidV1 is created in lowercase | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | Fix #57878 | License | MIT Ensure `$this->uid` is in lowercase in UuidV1 (see #57878 for context) (strtolower is already called in the parent::__construct... but not when $args is null. And the uuid extension generates uppercase values --at least sometimes--). Not sure if should be considered a "bug" / which version to flag ? Commits ------- 9abfd25 [Uid] Ensure UuidV1 is created in lowercase
Symfony version(s) affected
6.4, 7.0, 7.1 (?)
Description
I found a strange bug while running the FrameworkBundle tests locally
It took me some time to realize my local PHP still had the "uid" extension installed.
So the problem comes down to this in
uuid_create
from the Symfony polyfill only generates lowercase strings, but theuuid_create
from the extension does not.So when the ArgumentResolver works, as it set the
$uuid
arguments, theparent::__construct
is called, where astrtolower
is applied to$this-uid
How to reproduce
Install the uuid extension and run the FrameworkBundle functional tests
Possible Solution
Add a strtolower (or any optimized strtr) in the UuiV1 constructor ? (if so i'll open a PR)
Or do you think we need to ensure all uid values are stored internally in lowercase ?
...
Or this should not be considered a bug at all ?
Additional Context
No response
The text was updated successfully, but these errors were encountered: