From 3d94e90a496282fdd202fda60180d5c13c6a2f0a 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 @@ class XMLDataFormatter extends DataFormatter 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)"; }