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.
This commit is contained in:
Ed Wilde 2024-10-15 11:50:55 +13:00 committed by GitHub
parent 3a3fd02367
commit 3d94e90a49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)";
}