-
Notifications
You must be signed in to change notification settings - Fork 7.9k
uri: Do not copy the normalized URI when cloning RFC 3986 URIs #19588
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
Merged
TimWolla
merged 2 commits into
php:master
from
TimWolla:uri-rfc3986-clone-normalized-uri
Sep 7, 2025
+3
−7
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this change is correct. The
clone_uri
handler is used exclusively by theclone
object handler, which is needed for two things:TBH I used to have a TODO comment somewhere mentioning that the two use-cases should be disambiguated somehow so that the normalized member doesn't need to be cloned if not necessary. I removed this at last before I merged my last MR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that it is not incorrect, it's just less efficient than it could be. URI normalization should be “deterministic”, thus if we clone the URI and then retrieve a normalized field on the clone it will simply renormalize the same URI.
Given that non-with-er cloning should be a comparatively rare occurrence it seems reasonable to not optimize for this case to keep the with-er cloning simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, I see it now. I think the best option would still be to be able to handle both cases. The clone_uri handle could accept a bool flag, which could be passed by the clone obj handler. And the obj handler could determine the value by checking the current opcode I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. But for now with the current API, not copying the normalized URI seems safer / less prone to bugs. And the comment is definitely out of sync with the implementation.
Should we take this for now and then with the implementation of the with-ers take another look? Alternatively we can close and you can propose something yourself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really get this. What kind of bugs can happen if we also copy the normalized URI during cloning?
I don't see much point in removing these lines and then reading them later, unless I miss any fundamental issue with normalization. So I'd say that either I can try to implement the idea, or feel free to do something similar yourself if you are interested in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is the other approach I mentioned: #19744