TypeError null allowed where string required in argument 3 ($subject) of str_replace #6993
Labels
priority: medium
Issues which are important, but no one will go out of business.
severity: major
Feature is not working as expected and no work around available
type: bug
Indicates an unexpected problem or unintended behavior
Milestone
Before submitting an issue please check that you’ve completed the following steps:
Describe the bug
The customer reports the following error is logged:
To Reproduce
Steps to reproduce the behavior:
I'm not able to reproduce the error with
WP_DEBUG
enabled. However, we can see here in this part of the code:wp-rocket/inc/Engine/Optimization/RegexTrait.php
Lines 146 to 149 in 9d4f8ca
We need to ensure that
$html
is a non-empty string to prevent errors like this.Expected behavior
We should run a check to make sure
$html
is a string and just return if not.Maybe this line:
wp-rocket/inc/Engine/Optimization/RegexTrait.php
Line 147 in 9d4f8ca
Could become this:
if ( !is_string( $html ) || empty( $this->html_replace ) ) {
Additional context
Ticket: https://secure.helpscout.net/conversation/2710047950/512718/
Website: https://www.gjcyclingshop.be
Acceptance Criteria (for WP Media team use only)
Clear instructions for developers, to be added before the grooming
The text was updated successfully, but these errors were encountered: