PHP 8.1 - Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\collapse_text\Plugin\Filter\CollapseText->processChildItem()

Created on 5 August 2022, over 2 years ago
Updated 10 February 2024, 10 months ago

Problem/Motivation

PHP 8.1 has deprecated passing null values to many internal functions, like trim. This module uses trim in a few places without first checking if the value is null. This causes a

Steps to reproduce

Use PHP 8.1 and this module, and add text like this to a filter format configured to use collapse text:

[collapse title="some title"]
Some text
[/collapse]

Proposed resolution

Check if the values are null and use empty string if so.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

πŸ“Œ Task
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Fixed 10 months ago
  • πŸ‡«πŸ‡·France dydave

    Long overdue!

    Really sorry for the delay on the PHP-8.1 and D10 compatibility tickets.

    Thanks a lot Brian (@bkosborne) for the great help with the maintenance work and contributions on this module.
     

    After testing the issue myself, I was easily able to reproduce the issue with D10.2.2 and PHP 8.1, with the same error message:

    Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\collapse_text\Plugin\Filter\CollapseText->processChildItem() (line 277 of modules/custom/collapse_text/src/Plugin/Filter/CollapseText.php).

    The error disappeared after applying the patch from #3, which I then committed to the 2.0.x branch at #8.

    I'll keep digging in the issue queue and try to roll in a few of the easy fixes to prepare the next stable release.

    Thanks again very much for the great help, the patches, forks and testing feedback.
    Cheers!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024