Problem/Motivation
Running Cron triggers the following PHP 7.3 warning in the Drupal Watchdog log:
Deprecated function: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in JShrink\Minifier->loop() (line 228 of /modules/contrib/advagg/advagg_js_compress/jshrink.inc).
Proposed resolution
Check that the needle parameter is not empty prior to calling the strpos() function on line 228.
-
Remove the current line 228 from jshrink.inc:
if (strpos('(-+[@', $this->b) !== false) {
-
And, replace it with this new line 228:
if (!empty($this->b) && strpos('(-+[@', $this->b) !== false) {
Attaching a patch to reflect this proposed fix.
Remaining tasks
Review this proposed approach, suggest a more appropriate fix if one exists, and include the fix in order to support PHP 7.4+.
Comments
Comment #2
ericjenkins commentedAttaching patch #2 for review.
Comment #3
ericjenkins commentedComment #4
ericjenkins commentedComment #5
ericjenkins commentedIt appears I should have been checking for an empty needle string instead of casting the needle as a string.
Attaching updated patch #5 and interdiff.
Comment #6
ericjenkins commentedComment #7
acbramley commentedThis looks like a duplicate of #3068558: JShrink and PHP 7.3 issues