-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
[2.0] Validate mapping files against schema #1814
[2.0] Validate mapping files against schema #1814
Conversation
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.
Nice one 👍
$document->load($filename); | ||
|
||
try { | ||
$previousUseErrors = libxml_use_internal_errors(true); |
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.
Moving this outside of the try
block should be safe and satisfy PHPStan
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.
Ah yes, good point! 👍
There's no point enforcing a specific order of elements, so we replace sequence with choice for more flexibility.
ca7348e
to
4e73b85
Compare
Summary
With this change, invalid XML mapping files are no longer accepted by the XML driver. It also replaces the pesky
sequence
element in the schema withchoice
, allowing fields in any order the user wants to map them. This mirrors a change done in ORM a while ago.Last but not least, this removes leftover handling for the
id
attribute in thefield
mapping that should have been removed in #1807.When backporting this feature to 1.3, we have to introduce a strict mode for mapping files that is disabled by default. When disabled, it will trigger a deprecation warning to inform the user that it will throw exceptions in 2.0; when enabled, it will behave like the driver in 2.0 and throw exceptions on invalid mapping files.