wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

PHP Warnings after update and on 1st preload

Open hellofromtonya opened this issue 4 years ago • 47 comments

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

hellofromtonya avatar Mar 17 '20 11:03 hellofromtonya

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

Screenfeed avatar Mar 17 '20 13:03 Screenfeed

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

Screenfeed avatar Mar 17 '20 17:03 Screenfeed

@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?

hellofromtonya avatar Mar 17 '20 17:03 hellofromtonya

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 avatar Mar 17 '20 23:03 Screenfeed

@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 avatar Mar 17 '20 23:03 hellofromtonya

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

Screenfeed avatar Mar 17 '20 23:03 Screenfeed

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

hellofromtonya avatar Mar 18 '20 10:03 hellofromtonya

@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?

Screenfeed avatar Mar 23 '20 16:03 Screenfeed

Related ticket https://secure.helpscout.net/conversation/1116457464/153087/.

camilamadronero-zz avatar Mar 26 '20 20:03 camilamadronero-zz

Another related ticket: https://secure.helpscout.net/conversation/1127829424/155708?folderId=273761

GeekPress avatar Apr 04 '20 15:04 GeekPress

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?

crystinutzaa avatar Apr 06 '20 19:04 crystinutzaa

Customer to follow up when fixed:

  • https://secure.helpscout.net/conversation/1131879933/0/?folderId=273764

GeekPress avatar Apr 12 '20 13:04 GeekPress

Related ticket: https://secure.helpscout.net/conversation/1162724289/164680/

vmanthos avatar May 13 '20 09:05 vmanthos

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

hellofromtonya avatar May 26 '20 11:05 hellofromtonya

Related ticket: https://secure.helpscout.net/conversation/1215380071/177943?folderId=273766

juricazuanovic avatar Jul 05 '20 13:07 juricazuanovic

Related tickets: https://secure.helpscout.net/conversation/1231270616/181548 (requested a refund) WIP: https://secure.helpscout.net/conversation/1228142197/180871 (asked for credentials) WIP: https://secure.helpscout.net/conversation/1232604979/181835 (asked for credentials)

vmanthos avatar Jul 22 '20 13:07 vmanthos

https://secure.helpscout.net/conversation/1282059479/194792?folderId=377611

webtrainingwheels avatar Sep 18 '20 21:09 webtrainingwheels

https://secure.helpscout.net/conversation/1292817672/197645?folderId=273766

alfonso100 avatar Sep 26 '20 03:09 alfonso100

https://secure.helpscout.net/conversation/1295946218/198440?folderId=2683093

alfonso100 avatar Oct 01 '20 21:10 alfonso100

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

mzimma avatar Nov 23 '20 07:11 mzimma

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.

arunbasillal avatar Nov 23 '20 08:11 arunbasillal

Sounds good, thank you!

mzimma avatar Nov 23 '20 17:11 mzimma

Related ticket: https://secure.helpscout.net/conversation/1347367935/215413/

vmanthos avatar Nov 24 '20 12:11 vmanthos

Related ticket: https://secure.helpscout.net/conversation/1364738701/222493?folderId=2135277

vmanthos avatar Jan 13 '21 12:01 vmanthos

Related ticket - https://secure.helpscout.net/conversation/1488090663/257184/

DahmaniAdame avatar May 06 '21 06:05 DahmaniAdame

This still happens with current version 3.9.0.1, same error, but it just happened randomly, no upgrade was performing

quangthien27 avatar Jun 07 '21 13:06 quangthien27

i got the same random PHP Warning with 3.9.0.x from copy() on class-wp-filesystem-direct.php

olivM avatar Jul 03 '21 21:07 olivM

I do become the warning reoccuring. Version 3.9.0.5 on an IIS Based Azure App Service. It seems to be reproducable. in some cases the cache folder /site/wwwroot/wp-content/cache/wp-rocket/{fulldomainname} is deleted/notexistant. if the folder does not exists i do become the error on each page which is to be preloaded. if i recreate the folder manually the cache is build without these error. so currently my primary problem is the domain cache folder ist deleted by some (process).

HannesVo avatar Jul 27 '21 11:07 HannesVo

Related - https://secure.helpscout.net/conversation/1630916805/294657/

DahmaniAdame avatar Sep 15 '21 11:09 DahmaniAdame

related https://secure.helpscout.net/conversation/1728379095/314505/

alfonso100 avatar Dec 15 '21 21:12 alfonso100