-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Legacy TODO in XmlEncoder regarding root node name during decoding #61441 #61466
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
base: 7.4
Are you sure you want to change the base?
Legacy TODO in XmlEncoder regarding root node name during decoding #61441 #61466
Conversation
…name is provided; add tests for mismatch and missing root cases
Why we did this
Why this decision
What we understood
Why this is the best fit
Added
|
… with deprecation notice
Co-authored-by: Oskar Stark <oskarstark@googlemail.com>
Co-authored-by: Fabien Potencier <fabien@potencier.org>
throw new NotEncodableValueException(\sprintf('Expected root node "%s", but found "%s".', $expectedRootName, $rootNode->nodeName)); | ||
} | ||
|
||
trigger_deprecation('symfony/serializer', '7.4', 'Decoding XML with a mismatching root node name is deprecated and will throw an exception in 8.0. Expected root node "%s", but found "%s". Set the "%s" context option to true to enable validation now.', $expectedRootName, $rootNode->nodeName, self::VALIDATE_ROOT_NODE_NAME); |
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.
If not done already we need to require Symfony/deprecation-contracts
PR body needs an update after the change of the option name |
…false); deprecate throwing on missing root node; return empty array for BC when validation disabled; update tests to use correct constants
Add root node validation to
XmlEncoder::decode()
when configured via context options.What it does and why
This PR implements a long-standing TODO in
XmlEncoder::decode()
related to root node validation during decoding.New context options
validate_root_node_exists
(default:false
)true
: decoding throws if the XML has no valid root node.false
: decoding continues, but triggers a deprecation warning in 7.4 (will throw by default in 8.0).validate_root_node_name
(default:false
)true
: decoding throws if the root node name does not match the expectedroot_node_name
.false
: decoding continues, but triggers a deprecation warning in 7.4 (will throw by default in 8.0).Deprecations
Benefits
Example