Skip to content

Make the merged action group schema deterministic for libxml2 2.12+ - #931

Open
thai2301 wants to merge 1 commit into
magento:developfrom
thai2301:920-action-group-schema-deterministic
Open

thai2301 wants to merge 1 commit into
magento:developfrom
thai2301:920-action-group-schema-deterministic

Conversation

@thai2301

Copy link
Copy Markdown

Description

With libxml2 2.12 or later, loading mergedActionGroupSchema.xsd fails with:

complex type 'actionsRefType': The content model is not determinist., line 17

actionsRefType is a repeated choice of actions, followed by an optional sequence that starts with <xs:group ref="returnTags"/> and repeats the same choice. returnTags (Actions/customActions.xsd) declares return with minOccurs="0", so after the first choice loop the validator cannot tell whether the next action belongs to the first loop or to the optional sequence with an omitted return. libxml2 2.9 accepted this; 2.12 and later reject ambiguous content models (the same class of problem was fixed in magento/magento2#38553 for core schemas).

This change makes the sequence start with a required <xs:element type="returnType" name="return"/>. The sequence itself is still minOccurs="0", so the set of valid documents is the same: action groups without return, with one return followed by more actions, and still at most one return.

Checked against both libxml2 versions:

  • libxml2 2.14.6: the current schema fails to compile with the error above; with this change it compiles, and sample action groups with and without return validate.
  • libxml2 2.9.13 (PHP DOM): sample action groups with and without return validate before and after; an action group with two return elements is rejected before and after.
  • vendor/bin/phpunit -c dev/tests/phpunit.xml (unit and verification suites): 460 tests pass.

No new test: the existing verification tests already generate action groups that use return, and the ambiguity is only reported by libxml2 2.12+, so a test would only fail on CI images that ship it.

Fixed Issues (if relevant)

  1. "Schema validation error complex type 'actionsRefType': The content model is not determinist" Error Thrown While Generating Tests #920: Schema validation error complex type 'actionsRefType': The content model is not determinist

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/verification tests (if applicable)
  • All automated tests passed successfully (all builds are green)
  • Changes to Framework doesn't have backward incompatible changes for tests or have related Pull Request with fixes to tests

…12 and later

The optional sequence that starts with <return> referenced the returnTags
group, whose element is itself optional, so the content model of
actionsRefType was ambiguous. libxml2 2.12 and later reject such schemas
with "The content model is not determinist". The sequence now starts with
a required <return> element; the sequence itself stays optional, so the
accepted documents are unchanged.
@thai2301

Copy link
Copy Markdown
Author

@magento run all tests

This branch has not been deployed

No deployments
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.

1 participant