Wp-rocket: PHP Warnings after update and on 1st preload

Created on 17 Mar 2020  Â·  24Comments  Â·  Source: wp-media/wp-rocket

Describe the bug
The customer's debug log file is filled with PHP Warnings for _temp file extensions not found after updating to 3.5.0.3 and only on the 1st preload. Here's the log they shared:

[13-Mar-2020 08:29:55 UTC] PHP Warning:  copy(/home/****/wp-content/cache/wp-rocket/www.0creditcardexpert.co.uk/0-credit-card-abroad/index-https.html_gzip_temp): failed to open stream: No such file or directory in /home/****/wp-admin/includes/class-wp-filesystem-direct.php on line 281
[13-Mar-2020 08:30:09 UTC] PHP Warning:  chmod(): No such file or directory in /home/****/wp-admin/includes/class-wp-filesystem-direct.php on line 168
[13-Mar-2020 08:30:09 UTC] PHP Warning:  copy(/home/****/wp-content/cache/wp-rocket/www.0creditcardexpert.co.uk/credit-card-minimum-payment/index-mobile-https.html_gzip_temp): failed to open stream: No such file or directory in /home/****/wp-admin/includes/class-wp-filesystem-direct.php on line 281
[13-Mar-2020 08:30:10 UTC] PHP Warning:  copy(/home/****/wp-content/cache/wp-rocket/www.0creditcardexpert.co.uk/0-credit-card-abroad/index-mobile-https.html_gzip_temp): failed to open stream: No such file or directory in /home/****/wp-admin/includes/class-wp-filesystem-direct.php on line 281
[13-Mar-2020 08:30:21 UTC] PHP Warning:  copy(/home/****/wp-content/cache/wp-rocket/www.0creditcardexpert.co.uk/about/index-mobile-https.html_gzip_temp): failed to open stream: No such file or directory in /home/****/wp-admin/includes/class-wp-filesystem-direct.php on line 281
[13-Mar-2020 08:30:38 UTC] PHP Warning:  copy(/home/****/wp-content/cache/wp-rocket/www.0creditcardexpert.co.uk/press/index-mobile-https.html_temp): failed to open stream: No such file or directory in /home/****/wp-admin/includes/class-wp-filesystem-direct.php on line 281
[13-Mar-2020 08:30:41 UTC] PHP Warning:  chmod(): No such file or directory in /home/****/wp-admin/includes/class-wp-filesystem-direct.php on line 168
[13-Mar-2020 08:30:41 UTC] PHP Warning:  copy(/home/****/wp-content/cache/wp-rocket/www.0creditcardexpert.co.uk/privacy-policy/index-mobile-https.html_temp): failed to open stream: No such file or directory in /home/****/wp-admin/includes/class-wp-filesystem-direct.php on line 281
[13-Mar-2020 08:30:43 UTC] PHP Warning:  chmod(): No such file or directory in /home/****/wp-admin/includes/class-wp-filesystem-direct.php on line 168
[13-Mar-2020 08:30:43 UTC] PHP Warning:  copy(/home/****/wp-content/cache/wp-rocket/www.0creditcardexpert.co.uk/resources/index-mobile-https.html_temp): failed to open stream: No such file or directory in /home/****/wp-admin/includes/class-wp-filesystem-direct.php on line 281
  • The errors did not reoccur.
  • When launching a new preload, no warnings or errors were generated.
  • When updating to 3.5.0.4, no warnings or errors were generated.

To Reproduce
Steps to reproduce the behavior:

  1. Install 3.4.4.
  2. Generate the preload.
  3. Clear the debug log <- just to be sure.
  4. Update to 3.5.0.3.
  5. Check the debug log.

Expected behavior
Update and generate preload without PHP warnings.

Additional context

  • WordPress: v5.3.2
  • Rocket: 3.5.0.3
  • HS Ticket

Backlog Grooming

  • [x] Reproduce the problem
  • [x] Identify the root cause
  • [x] Scope a solution
  • [x] Estimate the effort
future cache preload medium minor blocked bug

Most helpful comment

I am not able to reproduce, but I got PHP notices instead. I'm opening a new issue related to those.

All 24 comments

I am not able to reproduce, but I got PHP notices instead. I'm opening a new issue related to those.

@hellofromtonya Should we contact this person to try to reproduce on their site?

@Screenfeed The steps that I laid out _might not be_ exact to what the customer did. He noted that it happened during update and 1st preload.

Could you try to reproduce it in different combinations of update and 1st preload?

It didn't happen for them again when updating to 3.5.0.4. What do you think might be contributing to such a problem?

Reproduce the problem ✅
This is not related to the update process, but happens when caching.

Identify the root cause ✅
This happens if the /wp-content/cache/wp-rocket/’s child folder is not writable. Here, it would be /wp-content/cache/wp-rocket/www.0creditcardexpert.co.uk/.

Scope a solution ✅
Add some tests like is_writable() in WP_Rocket\Buffer\Cache->maybe_process_buffer() and WP_Rocket\Buffer\Cache->write_cache_file().

Estimate the effort ✅
effort: [S]

@Screenfeed

  1. Why do you think the directory was not writeable after the update? It was before the update.
  2. What do you think made it writeable again after the 1st preload?

@hellofromtonya

  1. I can’t be sure but I think the site was in the middle of a caching process when the update triggered, leaving opened files/folders in an "intermediate" state. Then the upgrade from 3.4.4 to 3.5.0.3 doesn’t include a cache refresh.
  2. The person probably cleared the cache before launching the next preload.

Actually none of this makes sense to me, but I have no other explanations.

the site was in the middle of a caching process when the update triggered, leaving opened files/folders in an "intermediate" state. Then the upgrade from 3.4.4 to 3.5.0.3 doesn’t include a cache refresh

That's a good theory. @Screenfeed test it by:

  • Setting up that scenario and seeing if it produces the situation
  • If you can't recreate it, ask your teammates to try it

@crystinutzaa @Tabrisrp I am not able to reproduce my hypothesis in my last message.
Do you have other ideas and/or are you able to reproduce?

I was able to recreate this issue on my local.

The issue is that Partial Preload is running during upgrade.
This is the full stacktrace:

[06-Apr-2020 13:01:57 UTC] PHP Warning:  copy(/app/public/wp-content/cache/wp-rocket/wp3.local/index.html_temp): failed to open stream: No such file or directory in /app/public/wp-admin/includes/class-wp-filesystem-direct.php on line 281
[06-Apr-2020 13:01:57 UTC] PHP Stack trace:
[06-Apr-2020 13:01:57 UTC] PHP   1. shutdown_action_hook() /app/public/wp-includes/load.php:0
[06-Apr-2020 13:01:57 UTC] PHP   2. do_action() /app/public/wp-includes/load.php:947
[06-Apr-2020 13:01:57 UTC] PHP   3. WP_Hook->do_action() /app/public/wp-includes/plugin.php:478
[06-Apr-2020 13:01:57 UTC] PHP   4. WP_Hook->apply_filters() /app/public/wp-includes/class-wp-hook.php:312
[06-Apr-2020 13:01:57 UTC] PHP   5. wp_ob_end_flush_all() /app/public/wp-includes/class-wp-hook.php:288
[06-Apr-2020 13:01:57 UTC] PHP   6. ob_end_flush() /app/public/wp-includes/functions.php:4552
[06-Apr-2020 13:01:57 UTC] PHP   7. WP_Rocket\Buffer\Cache->maybe_process_buffer() /app/public/wp-includes/functions.php:4552
[06-Apr-2020 13:01:57 UTC] PHP   8. WP_Rocket\Buffer\Cache->write_cache_file() /app/public/wp-content/plugins/wp-rocket/inc/classes/Buffer/class-cache.php:308
[06-Apr-2020 13:01:57 UTC] PHP   9. WP_Filesystem_Direct->move() /app/public/wp-content/plugins/wp-rocket/inc/classes/Buffer/class-cache.php:352
[06-Apr-2020 13:01:57 UTC] PHP  10. WP_Filesystem_Direct->copy() /app/public/wp-admin/includes/class-wp-filesystem-direct.php:309
[06-Apr-2020 13:01:57 UTC] PHP  11. copy() /app/public/wp-admin/includes/class-wp-filesystem-direct.php:281

In this file the error occurs:
https://github.com/wp-media/wp-rocket/blob/00cf7a1c5e0b2e7354b0aa76ca86603ee4420eae/inc/classes/Buffer/class-cache.php#L341-L352

This is triggered by Partial Preload on maybe dispatch.
What I assume is happening is:

  1. Partial Preloading is running
  2. WP Rocket is being upgraded.
  3. Something happens during the upgrade (a Fatal Exception) which stops the Partial Preloading.
    No _temp file is created. Error is in error log.
  4. When upgrade is done everything is working just fine as before. Because _temp files are available and everything runs.

The solution is:
Stop Preloading / Partial Preloading during upgrading WP Rocket.

@Tabrisrp , @Screenfeed & @hellofromtonya

I cannot estimate how much effort this will take. 😄 Ideas?
Should this estimation be with the new Upgrading system we discussed today?

This issue will be fixed in a future major release. It's blocked until the new Preload is built.

When is the fix going to be released ? This seems to be related https://github.com/wp-media/wp-rocket/issues/3314

When is the fix going to be released ?

@mzimma We are planning to re-write our entire preload approach (no ETA yet). This will be fixed during the rewrite.

Sounds good, thank you!

Was this page helpful?
0 / 5 - 0 ratings