Problem/Motivation

If you are using advagg_js_compress which is a submodule and run the cron then cron goes into infinite loop.

Steps to reproduce

- Install the advagg and advagg_js_compress
- Run the cron via UI or drush
- It will never come back

Proposed resolution

- Issue in sites/all/modules/contrib/advagg/advagg_js_compress/jshrink.inc line 327. In PHP 7 substr returns the false but in PHP 8 it returns the '' empty string.

Remaining tasks

- Create the patch.

User interface changes

- No

API changes

- No

Data model changes

- No

Issue fork advagg-3277342

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

asghar created an issue. See original summary.

asghar’s picture

StatusFileSize
new493 bytes

alan-ps made their first commit to this issue’s fork.

alan-ps’s picture

Version: 7.x-2.34 » 7.x-2.x-dev
Status: Active » Needs review

Hi @asghar, I think we should keep backward compatibility here. So, I would rather use explicit casting to solve an issue

Dmitrii_Zadorozhnyi’s picture

StatusFileSize
new518 bytes

Hi!
For backward compatibility with PHP 7, i would like to change patch, according to https://www.php.net/manual/en/function.substr.php
For PHP 8 - "The function returns an empty string where it previously returned false."

darkodev’s picture

darkodev’s picture

Any reason we shouldn't take the approach used for D9 version and do a wholesale replacement of jshrink.inc? https://www.drupal.org/project/advagg/issues/3252394

darkodev’s picture

The patch in #6 works for us and applies cleanly to latest stable.

Drupal 7.92
Advagg 7.x-2.35
PHP 8.0.21

I tried the replacement of the whole jshrink.inc file from the D9 fix, and it also seems to work.

The solution there is the avoidance of substr()

+      // Otherwise we start pulling from the input.
+      $char = $this->index < $this->len ? $this->input[$this->index] : false;
+
+      // If the next character doesn't exist return false.
+      if (isset($char) && $char === false) {
+        return false;
+      }
eugene bocharov’s picture

+1 for #6. Just maybe isset($char) can be removed, because $char is always defined there.

Not sure we can use latest jshrink version while D7 minimum requirements is PHP 5.3, but for latest jshrink PHP 5.6.

About #9 - it seems that $this->len is undefined. The fragment can't be used without other code replacement.

avpaderno’s picture

Title: Advagg 7.x on PHP 8 - advagg_js_compress Cron stuck issue » advagg_js_compress() cron stuck issue
selinav’s picture

Same problem with Drup 9.4.8 and php 8.0.26
It works with the #2 patch.

Thank you.

wamwam’s picture

Drupal 7.94
PHP 8.0.21 or PHP 7.4.33
Advagg 7.x-2.35

After applying the patch, the Status report /admin/reports/status and Site configuration /admin/config stop responding. No problems seen on other pages.
If you cancel the patch everything works fine

joelpittet’s picture

I agree with @darkodev in #8 we should use #3252394-31: JShrink incompatible with PHP 8 I have a comment in #31 with a better solution than backporting the hardcoded class changes

damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community

#6 is working for me, setting this to RTBC as a simple solution.

alex.skrypnyk’s picture

Re-roll against latest released version (#6 does not apply) 7.x-2.35

thalles’s picture

Status: Reviewed & tested by the community » Needs work

@joelpittet, can you send us a patch with jShrink new version?

poker10’s picture

Thanks for working on this!

Unless we want to intentionally drop support for PHP < 5.6, I think I would prefer the simple fix in #6 (see the comment #10). I am also not sure if someone will be able to provide the more complicated patch as suggested by #8 in this D7 phase.

init90’s picture

Priority: Normal » Major

In my case, it leads to server lagging and interaction of site works. I've increased priority to higher.

The patch from #16 fixed the problem.

Talkless’s picture

#16 worked for me!

hargobind’s picture

Status: Needs work » Reviewed & tested by the community

#16 works for my sites as well.

Since this issue priority is Major, marking RTBC unless @poker10 or other maintainers have something to say about it.

The commit in #16 can go in now, and then someone can work on the backport for jShrink at a later date if it's still important.

  • poker10 committed 0566d5d7 on 7.x-2.x
    Issue #3277342 by alan-ps, asghar, Dmitrii_Zadorozhnyi, alex.skrypnyk,...
poker10’s picture

Status: Reviewed & tested by the community » Fixed

Even though there is a workaround mentioned in #3252394-31: JShrink incompatible with PHP 8, I think that it is worth fixing this as it is a small fix.

For others needing a newer jShrink, please check the approach mentioned in the comment #31 on the link above.

Committed and pushed this to 7.x-2.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.