8000 bug #46577 [Serializer] Fix ignore attribute in Xml files (alamirault) · symfony/symfony@91f79fa · GitHub
[go: up one dir, main page]

Skip to content

Commit 91f79fa

Browse files
committed
bug #46577 [Serializer] Fix ignore attribute in Xml files (alamirault)
This PR was merged into the 5.4 branch. Discussion ---------- [Serializer] Fix ignore attribute in Xml files | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #46463 | License | MIT Before this PR `foo` was ignored. Now it is not. ```xml <class name="Symfony\Component\Serializer\Tests\Fixtures\Annotations\IgnoreDummy"> <attribute name="foo" ignore="false" /> </class> ``` Instead of cast we now use `XmlUtils::phpize` like others XmlLoaders. Commits ------- 6cdcb1b [Serializer] Fix ignore attribute in Xml files
2 parents 18aea63 + 6cdcb1b commit 91f79fa

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

src/Symfony/Component/Serializer/Mapping/Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata)
7272
}
7373

7474
if (isset($attribute['ignore'])) {
75-
$attributeMetadata->setIgnore((bool) $attribute['ignore']);
75+
$attributeMetadata->setIgnore(XmlUtils::phpize($attribute['ignore']));
7676
}
7777

7878
foreach ($attribute->context as $node) {

src/Symfony/Component/Serializer/Tests/Fixtures/serialization.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<class name="Symfony\Component\Serializer\Tests\Fixtures\Annotations\IgnoreDummy">
3838
<attribute name="ignored1" ignore="true" />
3939
<attribute name="ignored2" ignore="true" />
40+
<attribute name="notIgnored" ignore="false" />
4041
</class>
4142

4243
<class name="Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummyParent">

src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public function testLoadIgnore()
107107
$attributesMetadata = $classMetadata->getAttributesMetadata();
108108
$this->assertTrue($attributesMetadata['ignored1']->isIgnored());
109109
$this->assertTrue($attributesMetadata['ignored2']->isIgnored());
110+
$this->assertFalse($attributesMetadata['notIgnored']->isIgnored());
110111
}
111112

112113
protected function getLoaderForContextMapping(): LoaderInterface

0 commit comments

Comments
 (0)
0