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
Another PHP 8 deprecation.
Steps to reproduce
Proposed resolution
Guard Link::prepareValue()
against empty $values['uri']
.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#7 | 3319954-deprecated-function-trim-7.patch | 508 bytes | znerol |
| |||
#2 | 3319954-deprecated-function-trim-2.patch | 2.1 KB | znerol |
|
Comments
Comment #2
znerol CreditAttribution: znerol commentedOutput of
git diff -w
(easier to read):Comment #3
znerol CreditAttribution: znerol commentedI can roll a patch with an early return if this is preferred. I.e.:
Comment #4
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedI think the approach in #3 is better.
It would also be good to have an automated test for this.
Does the link field get emptied when the passed value is
null
?Comment #5
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedIt looks like that this issue is also being handled in #3306211: Deprecated function: trim(): Passing null is deprecated as of PHP 8.
Comment #6
znerol CreditAttribution: znerol commented#3306211: Deprecated function: trim(): Passing null is deprecated as of PHP 8 is indeed similar but it handles
DateTargetBase
. This issue is inLink
target.Do you like to merge those two issues?
What is supposed to happen if after
prepareValue
$values['uri']
isNULL
?. Is that handled differently than if$values['uri']
is an empty string?If the output should be the empty string if null is passed in, then we could fix it the same way as in #3306211: Deprecated function: trim(): Passing null is deprecated as of PHP 8, namely (
$values['uri'] = trim((string) $values['uri']
).Comment #7
znerol CreditAttribution: znerol commentedThis patch implements idea from #3306211: Deprecated function: trim(): Passing null is deprecated as of PHP 8. No interdiff.txt, since this is a different approach than comment 2.
Comment #8
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedThis is fixed as part of #3306211: Deprecated function: trim(): Passing null is deprecated as of PHP 8.