strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated

Created on 11 April 2023, over 1 year ago
Updated 25 April 2023, over 1 year ago

Problem/Motivation

Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\webform\WebformSubmissionForm->isSharePage() (line 3144 of /modules/contrib/webform/src/WebformSubmissionForm.php)

Steps to reproduce

Execute a workflow via command line. $this->getRouteMatch()->getRouteName() returns as NULL.

Proposed resolution

Change the code to:

/**
* When executed via command line, $this->getRouteMatch()->getRouteName()
* returns NULL. Therefore, strpos(): Passing null to parameter #1
* ($haystack) of type string is deprecated.
*/
$route_name = $this->getRouteMatch()->getRouteName();

if (is_null($route_name)) {
return false;
} else {
return (strpos($this->getRouteMatch()->getRouteName(), 'entity.webform.share_page') === 0);
}

πŸ› Bug report
Status

Fixed

Version

6.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States Shefik

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

Comments & Activities

Production build 0.71.5 2024