Skip to content

Commit

Permalink
FIX Add protection against deprecated warning from `mb_check_encoding…
Browse files Browse the repository at this point in the history
…()` (#136)

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.
  • Loading branch information
edwilde authored Oct 23, 2024
1 parent 60c36ae commit c169fad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/DataFormatter/XMLDataFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)";
}

Expand Down

0 comments on commit c169fad

Please sign in to comment.