minor #30912 Restore previous state for libxml option (greg0ire)

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 e53bf5839b ,
which has the nasty side effect of making the Validator component test
suite break with this message:

Validation failed: No DTD found!

Commits
-------

dde74aa8c9 Restore previous state for libxml option
This commit is contained in:
Fabien Potencier 2019-04-06 17:26:39 +02:00
commit a815308bf6

View File

@ -115,7 +115,7 @@ EOF
return ['file' => $file, 'valid' => true];
}
libxml_use_internal_errors(true);
$internal = libxml_use_internal_errors(true);
$document = new \DOMDocument();
$document->loadXML($content);
@ -143,6 +143,9 @@ EOF
];
}
libxml_clear_errors();
libxml_use_internal_errors($internal);
return ['file' => $file, 'valid' => 0 === \count($errors), 'messages' => $errors];
}