From 59fa63fc855925bac9d0a65cad2a127033204ee4 Mon Sep 17 00:00:00 2001 From: Ed Wilde Date: Tue, 15 Oct 2024 11:50:55 +1300 Subject: [PATCH] FIX Add protection against deprecated warning from `mb_check_encoding()` When the `$fieldValue` is not set, the `mb_check_encoding()` function raises a deprecation warning. ``` [Deprecated] mb_check_encoding(): Calling mb_check_encoding() without argument is deprecated ``` So we make sure the field value is set before using it. --- src/DataFormatter/XMLDataFormatter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataFormatter/XMLDataFormatter.php b/src/DataFormatter/XMLDataFormatter.php index c4ba879..56689d9 100644 --- a/src/DataFormatter/XMLDataFormatter.php +++ b/src/DataFormatter/XMLDataFormatter.php @@ -126,7 +126,7 @@ public function convertDataObjectWithoutHeader(DataObject $obj, $fields = null, continue; } $fieldValue = $obj->obj($fieldName)->forTemplate(); - if (!mb_check_encoding($fieldValue, 'utf-8')) { + if (isset($fieldValue) && !mb_check_encoding($fieldValue, 'utf-8')) { $fieldValue = "(data is badly encoded)"; }