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

[FEATURE] added ability to create default/fixed value nodes during XSD Schema Validation #13184

Merged
merged 3 commits into from
Mar 14, 2019

Conversation

matthiashofele
Copy link

@matthiashofele matthiashofele commented Jan 15, 2018

Description

This feature adds the functionality / ability to use defined default values from xsd schemas in xml config nodes.

This was probably not implemented due to backwards-compatibility to PHP 5.4
The constant LIBXML_SCHEMA_CREATE was introduced in Libxml >= 2.6.14 (as of PHP >= 5.5.2)

As of now magento 2 has a php requirement of 7.0.2|7.0.4|~7.0.6|~7.1.0 and it should be safe to use that extended functionality to harness the full power of XSD-Schemas.

Changes applied to \Magento\Framework\Config\Dom::validateDomDocument
Tests supplied in \Magento\Framework\Config\Test\Unit\DomTest::testValidateWithDefaultValue

See DOMDocument::schemaValidate

Fixed Issues

XSD schemas can define default values for xs:attribute nodes, but the xsd-based schema validation does not merge the defined default values into the merged XML \DomDocument

This behaviour is fixed by calling \DOMDocument->schemaValidate() with param LIBXML_SCHEMA_CREATE

Matthias Herold added 2 commits January 15, 2018 16:46
…fault/fixed value nodes during XSD Schema Validation with flag 'LIBXML_SCHEMA_CREATE'
…earch/_files/search_request_merged.php for \Magento\Framework\Search\Request\Config\FileSystemReaderTest::testRead
@magento-engcom-team
Copy link
Contributor

@matthiasherold thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

@matthiashofele
Copy link
Author

matthiashofele commented Jan 24, 2018

To be able to use this feature effectively in production mode the interface \Magento\Framework\Config\ValidationStateInterface which defaults to \Magento\Framework\App\Arguments\ValidationState should always return true (actually checks for developer mode).

The ValidationStateInterface is injected and used within the class \Magento\Framework\Config\Reader\Filesystem

This probably will slow down the caching-process a little (done in \Magento\Framework\Config\Data).
Once the caching is done the possibilty of being able to define default values for xml definitions far outweights the caching slowdown.

@okorshenko okorshenko modified the milestones: January 2018, February 2018 Feb 7, 2018
@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Oct 5, 2018

Hi @slavvka, thank you for the review.
ENGCOM-3466 has been created to process this Pull Request

@sivaschenko sivaschenko self-assigned this Jan 18, 2019
@okorshenko okorshenko removed this from the Release: 2.3.1 milestone Jan 28, 2019
@p-bystritsky p-bystritsky self-assigned this Mar 6, 2019
@ghost ghost added the Progress: accept label Mar 6, 2019
@magento-engcom-team magento-engcom-team merged commit e6bee7e into magento:2.3-develop Mar 14, 2019
@ghost
Copy link

ghost commented Mar 14, 2019

Hi @matthiasherold, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.2 milestone Mar 14, 2019
magento-engcom-team pushed a commit that referenced this pull request Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants