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

ericjenkins created an issue. See original summary.

ericjenkins’s picture

Attaching patch #2 for review.

ericjenkins’s picture

Issue summary: View changes
ericjenkins’s picture

Issue summary: View changes
ericjenkins’s picture

Issue summary: View changes
StatusFileSize
new640 bytes
new599 bytes

It 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.

ericjenkins’s picture

Status: Active » Needs review
acbramley’s picture

Status: Needs review » Closed (duplicate)

This looks like a duplicate of #3068558: JShrink and PHP 7.3 issues