Conversation
`clone $document` produced a copy whose nodes (components, properties and parameters) still had the ORIGINAL document as their root: - Document had no __clone(), so the copy's own root still pointed to the original (the constructor sets it to itself); - Component::__clone() gives each cloned child `$this->root`, i.e. the original, and grand-children are cloned before their parent's root is fixed; - Property::__clone() re-parents the cloned parameters but never sets their root. Anything that goes through the root was then resolved against the original. In particular DateTime::getDateTimes() resolves a TZID with TimeZoneUtil::getTimeZone($tzid, $this->root): once the original is destroyed (Sabre does it at the end of validateICalendar()) or rewritten, the VTIMEZONE of the copy is not found anymore, and a non-IANA TZID (e.g. `TZID=Custom Eastern` with `X-LIC-LOCATION:America/New_York`) silently falls back to the default PHP timezone. IANA TZIDs were not affected since they resolve without a VTIMEZONE. Document::__clone() now publishes the copy under construction for the duration of the deep copy, and every cloned component/property/parameter takes it as its root. This adds no traversal: a clone costs the same as before. Cloning a sub-component or a property (to add it back to the same document) still keeps the original document as root. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
vttranlina
approved these changes
Sep 24, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
clone $documentproduced a copy whose nodes (components, properties and parameters) still had the ORIGINAL document as their root:$this->root, i.e. the original, and grand-children are cloned before their parent's root is fixed;Anything that goes through the root was then resolved against the original. In particular DateTime::getDateTimes() resolves a TZID with TimeZoneUtil::getTimeZone($tzid, $this->root): once the original is destroyed (Sabre does it at the end of validateICalendar()) or rewritten, the VTIMEZONE of the copy is not found anymore, and a non-IANA TZID (e.g.
TZID=Custom EasternwithX-LIC-LOCATION:America/New_York) silently falls back to the default PHP timezone. IANA TZIDs were not affected since they resolve without a VTIMEZONE.Document::__clone() now publishes the copy under construction for the duration of the deep copy, and every cloned component/property/parameter takes it as its root. This adds no traversal: a clone costs the same as before. Cloning a sub-component or a property (to add it back to the same document) still keeps the original document as root.