Skip to content

Commit 5179fcf

Browse files
committed
bug #39068 [DependencyInjection][Translator] Silent deprecation triggered by libxml_disable_entity_loader (jderusse)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [DependencyInjection][Translator] Silent deprecation triggered by libxml_disable_entity_loader | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #39040 | License | MIT | Doc PR | - The XML entity loader is disabled by default since libxml 2.9 But, since PHP 8.0, calling the method `libxml_disable_entity_loader` triggers a deprecation which has been solved in symfony by calling `libxml_disable_entity_loader` only for libxml < 2.9 The issue is, some dependencies, enable the entity loader and does not restore the initial state afterward, leading to exceptions triggered by Symfony iteself. In previous versions symfony was resilient by disabling the flag before working, which is not the case anymore to avoid the deprecation. This PR restore the resiliency of Symfony for PHP < 8.0, which is not yet deprecated. But we have no way to check the status of the entity loader without triggering a deprecation with Symfony 8. Commits ------- 114b7a543a [DependencyInjection][Translator] Silent deprecation triggered by libxml_disable_entity_loader
2 parents fc95078 + 3261ce1 commit 5179fcf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Tests/Resources/TranslationFilesTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ public function testTranslationFileIsValid($filePath)
2929
$this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
3030
}
3131

32+
/**
33+
* @dataProvider provideTranslationFiles
34+
* @group Legacy
35+
*/
36+
public function testTranslationFileIsValidWithoutEntityLoader($filePath)
37+
{
38+
$document = new \DOMDocument();
39+
$document->loadXML(file_get_contents($filePath));
40+
libxml_disable_entity_loader(true);
41+
42+
$errors = XliffUtils::validateSchema($document);
43+
44+
$this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
45+
}
46+
3247
public function provideTranslationFiles()
3348
{
3449
return array_map(

0 commit comments

Comments
 (0)