Skip to content

Commit

Permalink
minor #30912 Restore previous state for libxml option (greg0ire)
Browse files Browse the repository at this point in the history
This PR was submitted for the master branch but it was merged into the 4.2 branch instead (closes #30912).

Discussion
----------

Restore previous state for libxml option

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Whenever libxml_use_internal_errors() is called, the previous value for
it should be restored. This used to be the case in this piece of code,
but it was wrongly removed in e53bf58 ,
which has the nasty side effect of making the Validator component test
suite break with this message:

Validation failed: No DTD found!

Commits
-------

dde74aa Restore previous state for libxml option
  • Loading branch information
fabpot committed Apr 6, 2019
2 parents f88a79b + dde74aa commit a815308
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -115,7 +115,7 @@ private function validate($content, $file = null)
return ['file' => $file, 'valid' => true];
}

libxml_use_internal_errors(true);
$internal = libxml_use_internal_errors(true);

$document = new \DOMDocument();
$document->loadXML($content);
Expand Down Expand Up @@ -143,6 +143,9 @@ private function validate($content, $file = null)
];
}

libxml_clear_errors();
libxml_use_internal_errors($internal);

return ['file' => $file, 'valid' => 0 === \count($errors), 'messages' => $errors];
}

Expand Down

0 comments on commit a815308

Please sign in to comment.