Problem/Motivation
\Drupal\dblog\Controller\DbLogController::createLink() can cause deprecations on PHP 8.1 because it passes NULLs to string functions.
Steps to reproduce
Run \Drupal\Tests\dblog\Functional\DbLogTest on PHP 8.1
Proposed resolution
Check $uri is not null before passing to UrlHelper::isValid()
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3240182-2.patch | 626 bytes | alexpott |
Comments
Comment #2
alexpottHere's the fix from the meta.
Comment #3
alexpottComment #4
daffie commentedThe value of $uri goes into a
preg_match()function as the second parameter (in the methodisValid()) and that must be a string in PHP 8.1.Looks good to me.
Comment #5
catch::createLink() is only called in two places, can we fix the callers instead?
Comment #6
dagmarI think the approach in #3 is correct, given this is a bad use of the UrlHelper::isValid API (which expects a string). Also the method still does what the documentation of that method says it does.
But also inspecting the code of the UrlHelper there are other examples of methods that expect a string but does not specify the full type-hint. I guess this is what is discussed here #3050720: [Meta] Implement strict typing in existing code
Comment #7
andypost@catch +1 RTBC as this protected method expects to deal with NULL as it documents in its doc-block
Comment #9
catchOK, fair enough.
Committed 09cf315 and pushed to 9.3.x. Thanks!