diff --git a/CHANGELOG.md b/CHANGELOG.md index fcbb299d..bff373ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. +## [3.10.1] - 2026-02-10 +- Fixed: exception in FormatterUtil when value is null + ## [3.10.0] - 2026-01-22 - Added: Option to adjust the field where the alias is generated from (instead of overriding the complete method) ([#106](https://github.com/heimrichhannot/contao-utils-bundle/pull/106)) - Added: AliasFieldConfiguration::setGenerateAliasCallback() ([#106](https://github.com/heimrichhannot/contao-utils-bundle/pull/106)) diff --git a/src/EntityFinder/Element.php b/src/EntityFinder/Element.php index 6fef5e84..939075b3 100644 --- a/src/EntityFinder/Element.php +++ b/src/EntityFinder/Element.php @@ -12,7 +12,7 @@ public function __construct( public readonly int $id, public readonly string $table, public readonly ?string $description = null, - public readonly ?iterable $parents = null + public readonly iterable|null $parents = null ) { } diff --git a/src/Util/FormatterUtil.php b/src/Util/FormatterUtil.php index 3412a294..912e1a08 100644 --- a/src/Util/FormatterUtil.php +++ b/src/Util/FormatterUtil.php @@ -168,9 +168,12 @@ public function formatDcaFieldValue( : $reference; } - if ($settings->replaceInsertTags) - { - $value = $this->insertTagParser->replace($value); + if (is_int($value) || null === $value) { + return $value; + } + + if ($settings->replaceInsertTags) { + $value = $this->insertTagParser->replace((string)$value); } return Str::specialchars($value); diff --git a/tests/Util/FormatterUtilTest.php b/tests/Util/FormatterUtilTest.php index 9f58883b..33178022 100644 --- a/tests/Util/FormatterUtilTest.php +++ b/tests/Util/FormatterUtilTest.php @@ -70,5 +70,16 @@ public function testFormatDcaFieldValue() ->setDcaOverride(['inputType' => 'text']) ) ); + + $this->assertEquals( + '', + $formatterUtil->formatDcaFieldValue( + $dataContainer, + 'message', + null, + FormatterUtil\FormatDcaFieldValueOptions::create() + ->setDcaOverride(['inputType' => 'textarea']) + ) + ); } } \ No newline at end of file