Problem/Motivation
Using Drupal 9.3.6 and upgraded from PHP 7.4 to PHP 8.1
Now I get the following error:
Deprecated function: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Html::escape() (line 424 of core/lib/Drupal/Component/Utility/Html.php).
Drupal\Component\Utility\Html::escape(NULL) (Line: 125)
Drupal\feeds\Controller\ItemListController->listItems(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 317)
Drupal\cleantalk\EventSubscriber\BootSubscriber->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 57)
Drupal\advban\AdvbanMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 265)
Drupal\shield\ShieldMiddleware->bypass(Object, 1, 1) (Line: 221)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Comments
Comment #2
jsidigital commentedComment #3
jsidigital commentedManaged to get error out with the attached patch that is based on similar issue here:
https://www.drupal.org/project/drupal/issues/3255637
Not sure if that works for anyone else or if it passes tests.
Would appreciate it if someone double checks that.
Thank you.
Comment #4
cilefen commentedComment #5
larowlanThe trace shows this is coming from the feeds module
Comment #6
megachrizDoes this fix the issue?
Comment #7
megachrizClosed #3266703: Deprecated mb_strlen() on Unicode.php using PHP 8.1 as a duplicate.
Comment #8
megachrizI just tested the patch manually with PHP 8.1. It turns out sanitizing isn't necessary. The value
<script>alert('hi')</script>would get displayed as<script>alert('hi')</script>.So the attached patch removes the
Html::escape()call.Will commit it if tests still pass.
Comment #10
megachrizCommitted #8.