Problem/Motivation
In CommentTokensHooks::tokens(), the homepage token replacement calls UrlHelper::stripDangerousProtocols($comment->getHomepage()) unconditionally. However, Comment::getHomepage() returns NULL when the homepage field has no value (it reads $this->get('homepage')->value which is NULL for an empty URI field).
UrlHelper::stripDangerousProtocols() expects a string parameter. Passing NULL causes a deprecation notice (Passing null to parameter #1 ($haystack) of type string is deprecated from the internal strpos() call)
This affects any token replacement involving [comment:homepage] when the comment author did not provide a homepage URL, which is the common case for authenticated users.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3578193
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
jurgenhaasI've fixed the test by adding another entry to the phpstan baseline following the pattern of around 45 others doing the same.
Comment #4
smustgrave commented1 small comment on the MR.
Comment #5
jurgenhaasCombined the tests.
Comment #6
smustgrave commentedThanks!
Comment #7
alexpottCommitted and pushed 65bd47cd354 to main and ece978bbaab to 11.x and 0c0189c2c1a to 11.3.x. Thanks!