Skip to content
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

Expose the XSD validation in the DoctrineOrmMappingsPass #1679

Merged
merged 1 commit into from
Jun 28, 2023

Conversation

stof
Copy link
Member

@stof stof commented Jun 27, 2023

Closes #1647

This allows bundles registering a custom mapping through the DoctrineOrmMappingsPass to opt-in for the XSD validation, which was forgotten when adding support for this opt-in in other places in the bundle.

@stof stof added this to the 2.10.1 milestone Jun 27, 2023
@stof stof requested review from greg0ire and dmaicher June 27, 2023 15:47
Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving in case my comment is irrelevant.

{
$locator = new Definition(SymfonyFileLocator::class, [$namespaces, '.orm.xml']);
$driver = new Definition(XmlDriver::class, [$locator]);
$driver = new Definition(XmlDriver::class, [$locator, null, $enableXsdValidation]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous situation, we were omitting the second argument. I think as a result, XmlDriver::DEFAULT_FILE_EXTENSION was used: https://github.com/doctrine/orm/blob/55d477dc507a52675c5a61267a00d389c71182f4/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php#L50

Suggested change
$driver = new Definition(XmlDriver::class, [$locator, null, $enableXsdValidation]);
$driver = new Definition(XmlDriver::class, [$locator, XmlDriver::DEFAULT_FILE_EXTENSION, $enableXsdValidation]);

If I don't sound very sure about this, that's because its value is .dcm.xml, and I don't recall ever seeing that extension in Symfony projects. Also, on line 71, .orm.xml is mentioned so maybe it takes over somehow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extension argument of the driver is ignored when passing a locator anyway. It is used only when passing a path.

And the locator we use uses the default extension of the simplified driver, which is not the same, so it would be confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix XSD valdiation deprecation from ORM
3 participants