Deprecated: strpos(): Passing null is deprecated in TMGMTLocalBreadcrumbBuilder

Created on 23 July 2025, 12 days ago

Problem/Motivation

Getting a deprecation warning on PHP 8.3 when running tests:

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /modules/contrib/tmgmt/translators/tmgmt_local/src/Menu/TMGMTLocalBreadcrumbBuilder.php on line 23

The code in question is this:

    if (strpos($route_match->getRouteName(), 'view.tmgmt_local_manage_translate_task') === 0 || strpos($route_match->getRouteName(), 'view.tmgmt_local_task_overview') === 0 ||
      $route_match->getParameter('tmgmt_local_task') instanceof LocalTaskInterface || $route_match->getParameter('tmgmt_local_task_item') instanceof LocalTaskItemInterface) {
      return TRUE;
    }

It happens because $route_match->getRouteName() can return NULL if there is no route, e.g. when running on the CLI.

🐛 Bug report
Status

Active

Version

1.0

Component

Translator: Local

Created by

🇧🇬Bulgaria pfrenssen Sofia

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

Comments & Activities

Production build 0.71.5 2024