Skip to content

fix: remove dead libxml_set_external_entity_loader guard in Config Dom#40944

Open
lbajsarowicz wants to merge 1 commit into
magento:2.4-developfrom
lbajsarowicz:fix/config-dom-libxml-dead-guard
Open

fix: remove dead libxml_set_external_entity_loader guard in Config Dom#40944
lbajsarowicz wants to merge 1 commit into
magento:2.4-developfrom
lbajsarowicz:fix/config-dom-libxml-dead-guard

Conversation

@lbajsarowicz

@lbajsarowicz lbajsarowicz commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Description

Remove the dead libxml_set_external_entity_loader() availability guard from Magento\Framework\Config\Dom::validateDomDocument().

Problem

The method starts with a guard that is always false:

if (!function_exists('libxml_set_external_entity_loader')) {
    return [];
}

libxml_set_external_entity_loader() is provided by ext-libxml, which is bundled with PHP and cannot be disabled; the function has existed since PHP 5.4. Since Magento requires PHP 8.3+, this branch is unreachable.

Worse, if the branch were ever taken it would return an empty error list — silently skipping XSD schema validation entirely and reporting the document as valid.

Solution

Remove the dead guard. Behavior on every supported PHP version is unchanged.

Files Changed

  • lib/internal/Magento/Framework/Config/Dom.php

Related Pull Requests

Same cleanup pattern as #40686, #40687, #40688.

Manual testing scenarios (*)

  1. Run lib/internal/Magento/Framework/Config/Test/Unit/DomTest.php — all validation tests pass.
  2. Run the Magento/Framework/Config integration suite — schema validation behaves as before.

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/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] fix: remove dead libxml_set_external_entity_loader guard in Config Dom #40950: fix: remove dead libxml_set_external_entity_loader guard in Config Dom

Magento 2.4-develop only supports PHP versions where ext-libxml provides
libxml_set_external_entity_loader(), so this early return is unreachable.

Removing it also prevents schema validation from being silently skipped
if the guard were ever taken.
@m2-assistant

m2-assistant Bot commented Jul 6, 2026

Copy link
Copy Markdown

Hi @lbajsarowicz. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@lbajsarowicz

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@engcom-Hotel

Copy link
Copy Markdown
Contributor

@magento create issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P3 May be fixed according to the position in the backlog. Progress: pending review

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

[Issue] fix: remove dead libxml_set_external_entity_loader guard in Config Dom

2 participants