Closed NataliaDrause closed 3 years ago
[x] Reproduce the problem Yes I saw the issue on customer site.
[x] Identify the root cause
At 3.8 we removed safe mode for jquery
option on this PR https://github.com/wp-media/wp-rocket/pull/3366 and there we used the filter rocket_defer_inline_exclusions
and pass it a string and then on the next minor release (3.8.1) we changed it's type to be array on this PR https://github.com/wp-media/wp-rocket/pull/3424
so if there is a code is using our 3.8 approach it will fail with our newer versions after 3.8
[x] Scope a solution
We need to guard our filter value here
https://github.com/wp-media/wp-rocket/blob/b5edbea55c84f6d413b5b89e30d5015723e7b349/inc/Engine/Optimization/DeferJS/DeferJS.php#L136
so here we will check the type of it, if string we will explode it with the delimiter |
and then force casting it to be array.
[x] Estimate the effort [XS] it will need adding new test case to pass different types of data to this filter.
Before submitting an issue please check that you’ve completed the following steps:
Describe the bug 3rd party plugins use our filter
rocket_defer_inline_exclusions
and pass a string instead of an array. This leads to a PHP warning in the debug.log:PHP Warning: Invalid argument supplied for foreach() in /home4/nataliad/testsite.nataliadrause.com/wp-content/plugins/wp-rocket/inc/Engine/Optimization/DeferJS/DeferJS.php on line 140
Such errors were caused by compatibility codes in ShortPixel AI and Smart Slider 3 plugins so far.
To Reproduce Steps to reproduce the behavior:
Expected behavior There should be no errors.
Additional context Code in ShortPixel AI:
Comment by @engahmeds3ed:
Slack convo: https://wp-media.slack.com/archives/C43T1AYMQ/p1612871496110000 Ticket: https://secure.helpscout.net/conversation/1412614288/235953/
Related issue with Smart Slider 3: Slack: https://wp-media.slack.com/archives/C60QX4FC1/p1612456408103600 Ticket: https://secure.helpscout.net/conversation/1414913336/236541/
Backlog Grooming (for WP Media dev team use only)