Error when opening admin/structure/webform

Created on 2 September 2024, 7 months ago

Problem/Motivation

When I try to open /admin/structure/webform I get this error:
TypeError: str_contains(): Argument #1 ($haystack) must be of type string, array given in str_contains() (regel 80 van /var/www/html/web/modules/contrib/lb_plus/lb_plus.module).

The referring code is:
if (str_contains($message, 'You have unsaved changes.')) {

$message is indeed not a string. If I output it, its an array:

array:2 [▼
  0 => array:4 [▼
    "#type" => "link"
    "#title" => "×"
    "#url" => 
Drupal\Core
\
Url {#6192 ▶}
    "#attributes" => array:2 [▼
      "aria-label" => 
Drupal\Core\StringTranslation
\
TranslatableMarkup {#6183 ▶}
      "class" => array:2 [▶]
    ]
  ]
  1 => array:2 [▼
    "#theme" => "webform_help"
    "#info" => array:13 [▼
      "group" => "notifications"
      "content" => "
<strong>ATTENTION DEVELOPERS!!!</strong> Please make sure to download and update the <a href="https://github.com/RobinHerbots/Inputmask">Input Mask</a> library 
 ▶
"
      "message_id" => "webform_help_notification__webform_update_8187"
      "message_type" => "warning"
      "message_close" => true
      "message_storage" => "custom"
      "routes" => array:1 [▶]
      "id" => "webform_help_notification__webform_update_8187"
      "reset_version" => false
      "paths" => []
      "access" => true
      "video_id" => ""
      "attached" => []
    ]
  ]
]

Steps to reproduce

- enable lb_plus
- visit /admin/structure/webform

Proposed resolution

Add check for is_string():
if (is_string($message) && str_contains($message, 'You have unsaved changes.')) {

🐛 Bug report
Status

Active

Version

3.1

Component

Code

Created by

🇧🇪Belgium flyke

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

Comments & Activities

Production build 0.71.5 2024