Problem/Motivation

In Drupal 10 on PHP 8.2, viewing an Event Instance logs the following deprecation notice when the permitted registration roles area ("Which roles can register for this series?") is NULL when creating an event:

Deprecated function: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in Drupal\recurring_events_registration\RegistrationCreationService->registrationPermittedRoles() (line 885 of modules/contrib/recurring_events/modules/recurring_events_registration/src/RegistrationCreationService.php).

Steps to reproduce

Create an event with registration enabled.

Leave all of the checkboxes empty for the "Which roles can register for this series?" field.

Save the event.

View one of the event instances and see the deprecation notice in log or displayed, according to your site's settings.

Proposed resolution

Add a check within registrationPermittedRoles() method to make sure permitted roles is not empty.

Comments

endless_wander created an issue. See original summary.

chrisla’s picture

Title: Empty array not permitted in PHP 8 if event registration is not limited to any roles » Empty variable not permitted in PHP 8 str_replace if event registration is not limited to any roles
chrisla’s picture

Status: Active » Needs review
StatusFileSize
new1.51 KB

Patch to provide fix to catch empty string earlier

  • owenbush committed 1dc2b6d0 on 2.0.x
    Issue #3406137 by endless_wander: Empty variable not permitted in PHP 8...
owenbush’s picture

Status: Needs review » Fixed

Good catch, thanks for the fix. Merged into 2.0.x

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.