Skip to content

Commit

Permalink
IBX-6640: Fixed infinite loop when Normalizer returns an object
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveb-p committed Sep 26, 2023
1 parent 56a9d08 commit 516ec59
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/Output/Generator/Xml/FieldTypeHashGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ private function generateObjectValue(object $value, \XmlWriter $writer, ?string
]);
$value = null;
}

if (is_object($value)) {
return;
}

$this->generateValue($writer, $value, $key, $elementName);
}
}
Expand Down
14 changes: 14 additions & 0 deletions tests/lib/Output/Generator/FieldTypeHashGeneratorBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@ public function testGenerateUsingNormalizer(): void
$this->assertSerializationSame(__FUNCTION__);
}

public function testGenerateObjectUsingNormalizer(): void
{
$object = (object)[];
$this->getNormalizer()
->expects(self::once())
->method('normalize')
->with(self::identicalTo($object))
->willReturnArgument(0);

$this->getGenerator()->generateFieldTypeHash('fieldValue', $object);

$this->assertSerializationSame(__FUNCTION__);
}

public function testGenerateWithMissingNormalizer(): void
{
$object = (object)[];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Field":{"fieldValue":{}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Field/>

0 comments on commit 516ec59

Please sign in to comment.