Skip to content

Passing null parameter to str_replace() makes wordpress debug to give an error on PHP > 8.1 #26

Description

@Webstijlen

Passing null parameter to str_replace() makes wordpress debug to give an error on PHP > 8.1

Error

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/html/wp-content/plugins/highlighting-code-block/class/loos_hcb.php on line 79

Environment
Using PHP 8.3

Fix

/highlighting-code-block/class/loos_hcb.php
Rule number 80

Situation Now

$content = str_replace( 'prism on-numbers', 'prism line-numbers', $content );

Proposal

$content = str_replace( 'prism on-numbers', 'prism line-numbers', $content ?? '');

References

https://magento.stackexchange.com/posts/369717/timeline

tested and error message is gone

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions