Problem/Motivation

When displaying content with bLazy enabled, one gets warnings on PHP 8.1

Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\blazy\BlazyManagerBase->getIoSettings() (line 293 of modules/contrib/blazy/src/BlazyManagerBase.php).

Proposed resolution

Patch BlazyManagerBase::getIoSettings() by null-coalescing the trim() argument to an empty string:

    $thold = trim($this->configLoad('io.threshold') ?? "");

Remaining tasks

Convert to patch or merge request.

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#7 3265909-7-do-not-test.patch630 bytesandyf
#3 3265909-php81-3.patch567 bytesfgm

Comments

fgm created an issue. See original summary.

fgm’s picture

Issue summary: View changes
fgm’s picture

Status: Active » Needs review
StatusFileSize
new567 bytes

  • gausarts committed f9605c1 on 8.x-2.x authored by fgm
    Issue #3265909 by fgm: Warning with PHP 8.1: Deprecated function: trim()
    
gausarts’s picture

Title: Warning with PHP 8.1 » Warning with PHP 8.1: Deprecated function: trim()
Status: Needs review » Fixed

I couldn't reproduce it, likely because I had saved Blazy UI form thus far, and the value was already a string :)
But it will surely spit the warning before anyone started to save the Blazy UI form, so thanks for the catch.

Committed. Thank you for contribution.

Status: Fixed » Closed (fixed)

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

andyf’s picture

StatusFileSize
new630 bytes

I believe this is the equivalent patch for 2.5 if you're still using that.

Thanks!

manikandank03’s picture

Patch #7 works fine for the 2.5 version with PHP 8.1, thanks @Andyf