Problem/Motivation

\Drupal\user\AccountForm::buildEntity() causes deprecations in PHP 8.1 due to code in the contact module.

Steps to reproduce

https://3v4l.org/BYRl7

$v=NULL;var_dump(trim($v));

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated

Proposed resolution

Provide default value as empty string to prevent

Remaining tasks

review/commit

User interface changes

no

API changes

no

Data model changes

no

Release notes snippet

no

CommentFileSizeAuthor
#2 3240192-2.patch609 bytesandypost
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost created an issue. See original summary.

andypost’s picture

Status: Needs work » Needs review
FileSize
609 bytes
Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Makes sense I think, the whole thing could also be wrapped into a hasValue, but that's a bigger change and we'd end up checking twice, before and after trim().

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

#3 nicely sums why I made the change this way when I made it on #3220021: [meta] Ensure compatibility of Drupal 9 with PHP 8.1 (as it evolves).

Committed 1cdc36b and pushed to 9.3.x. Thanks!

  • alexpott committed 1cdc36b on 9.3.x
    Issue #3240192 by andypost, Berdir: \Drupal\user\AccountForm::...

Status: Fixed » Closed (fixed)

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