[WxT 5.2] Deprecated function: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\Core\Block\Plugin\Block\PageTitleBlock->build()

Created on 19 January 2024, 10 months ago
Updated 15 February 2024, 9 months ago

Problem/Motivation

- I see this warning when installing WxT 5.2.0 (PHP 8.2) and going to /admin/modules:

Deprecated function: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\Core\Block\Plugin\Block\PageTitleBlock->build() (line 114 of /var/www/html/html/core/lib/Drupal/Core/Block/Plugin/Block/PageTitleBlock.php)
#0 /var/www/html/html/core/includes/bootstrap.inc(164): _drupal_error_handler_real(8192, 'str_contains():...', '/var/www/html/h...', 114)
#1 [internal function]: _drupal_error_handler(8192, 'str_contains():...', '/var/www/html/h...', 114)
#2 /var/www/html/html/core/lib/Drupal/Core/Block/Plugin/Block/PageTitleBlock.php(114): str_contains(NULL, 'MoveBlockContro...')
#3 /var/www/html/html/core/modules/block/src/BlockViewBuilder.php(171): Drupal\Core\Block\Plugin\Block\PageTitleBlock->build()
#4 [internal function]: Drupal\block\BlockViewBuilder::preRender(Array)
#5 /var/www/html/html/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(111): call_user_func_array('Drupal\\block\\Bl...', Array)
#6 /var/www/html/html/core/lib/Drupal/Core/Render/Renderer.php(858): Drupal\Core\Render\Renderer->doTrustedCallback('Drupal\\block\\Bl...', Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
#7 /var/www/html/html/core/lib/Drupal/Core/Render/Renderer.php(421): Drupal\Core\Render\Renderer->doCallback('#pre_render', 'Drupal\\block\\Bl...', Array)
#8 /var/www/html/html/core/lib/Drupal/Core/Render/Renderer.php(493): Drupal\Core\Render\Renderer->doRender(Array)
#9 /var/www/html/html/core/lib/Drupal/Core/Render/Renderer.php(240): Drupal\Core\Render\Renderer->doRender(Array, false)
#10 /var/www/html/html/core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render(Array)
#11 

Steps to reproduce

- Install WxT 5.2.0 and go to /admin/modules, you should see the warning there.

Proposed resolution

It seems like this patch needs some extra casting to the 1st parameter when calling str_contains(), attached the same patch with the extra casting.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

5.2

Component

Code

Created by

🇨🇦Canada danrod Ottawa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024