Skip to content

Fix deprecation warning on empty str_replace() parameter - #158

Open
jhuhta wants to merge 1 commit into
h5p:masterfrom
jhuhta:fix-deprected-empty-parameter
Open

Fix deprecation warning on empty str_replace() parameter#158
jhuhta wants to merge 1 commit into
h5p:masterfrom
jhuhta:fix-deprected-empty-parameter

Conversation

@jhuhta

@jhuhta jhuhta commented Sep 28, 2023

Copy link
Copy Markdown

This fixes a deprecation error:

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/html/vendor/h5p/h5p-core/h5p.classes.php on line 1763

The error is given in Drupal on PHP 8.1 when saving a node with a H5P element.

@pjotrsavitski

Copy link
Copy Markdown

Thumbs up for the refactoring of str_replace functions enclosed into one another, although the code could be even more concise if you remove the empty check and just use the $value ?? '' instead. It will still be as readable and give the same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants