Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
\Drupal\user\AccountForm::buildEntity()
causes deprecations in PHP 8.1 due to code in the contact module.
Steps to reproduce
$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
Comment | File | Size | Author |
---|---|---|---|
#2 | 3240192-2.patch | 609 bytes | andypost |
Comments
Comment #2
andypostComment #3
BerdirMakes 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().
Comment #4
alexpott#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!