Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated

Created on 19 January 2023, almost 2 years ago
Updated 20 January 2023, almost 2 years ago

Problem/Motivation

When installing a site with install profile having dependency on notifications widget module we are the getting the following deprecation message on the configure screen

Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in notifications_widget_entity_insert() (line 92 of modules/contrib/notificationswidget/notifications_widget.module).
notifications_widget_entity_insert(Object, ‘block’)
call_user_func_array(Object, Array) (Line: 426)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, ‘notifications_widget’) (Line: 405)
Drupal\Core\Extension\ModuleHandler->invokeAllWith(‘entity_insert’, Object) (Line: 433)
Drupal\Core\Extension\ModuleHandler->invokeAll(‘entity_insert’, Array) (Line: 339)
Drupal\Core\Config\Entity\ConfigEntityStorage->invokeHook(‘insert’, Object) (Line: 598)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, ) (Line: 523)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 253)
Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object) (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 608)
...

Steps to reproduce

The development server should be running on php 8.1 or higher.

  1. Create a custom installation profile and add the notifcationswidget as a module.
  2. Run the drupal site install process
  3. Observe the error the Configure screen

Proposed resolution

Use the null coalescing operator for the explode functions

Remaining tasks

Validate the proposed fix.

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇳India arisen Goa

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Needs review almost 2 years ago
  • Status changed to RTBC almost 2 years ago
  • Status changed to Fixed almost 2 years ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024