Fixed Arr::stringToArray doesn't handle nulls gracefully


Well-known member
Affected version
The Arr::stringToArray is used on potentially nullable inputs, but trim requires non-null inputs as of php 8.1

An example of triggering this is;
                    /** @var \XF\Entity\ChangeLog $changeLog */
                    $changeLog = \XF::em()->create('XF:ChangeLog');
                    $changeLog->content_type = 'user';
                    $changeLog->content_id = 1;
//                    $changeLog->old_value = '';
                    $changeLog->new_value = implode(',', $intersect);
                    $changeLog->field = 'secondary_group_ids';
// the next line will error because old_value  is null
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.10).

Change log:
Properly handle null values within the Arr::stringToArray() function
There may be a delay before changes are rolled out to the XenForo Community.
The fix for this in 2.2.10 breaks on the string '0'. The test should be $string !== null || $string === '' rather than !$string.
Top Bottom