wp-rocket
wp-rocket copied to clipboard
PHP Warnings after update and on 1st preload
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:
- Install 3.4.4.
- Generate the preload.
- Clear the debug log <- just to be sure.
- Update to 3.5.0.3.
- 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
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
- Why do you think the directory was not writeable after the update? It was before the update.
- What do you think made it writeable again after the 1st preload?
@hellofromtonya
- 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.
- 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?
Related ticket https://secure.helpscout.net/conversation/1116457464/153087/.
Another related ticket: https://secure.helpscout.net/conversation/1127829424/155708?folderId=273761
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:
- Partial Preloading is running
- WP Rocket is being upgraded.
- Something happens during the upgrade (a Fatal Exception) which stops the Partial Preloading. No _temp file is created. Error is in error log.
- 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?
Customer to follow up when fixed:
- https://secure.helpscout.net/conversation/1131879933/0/?folderId=273764
Related ticket: https://secure.helpscout.net/conversation/1162724289/164680/
This issue will be fixed in a future major release. It's blocked until the new Preload is built.
Related ticket: https://secure.helpscout.net/conversation/1215380071/177943?folderId=273766
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)
https://secure.helpscout.net/conversation/1282059479/194792?folderId=377611
https://secure.helpscout.net/conversation/1292817672/197645?folderId=273766
https://secure.helpscout.net/conversation/1295946218/198440?folderId=2683093
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!
Related ticket: https://secure.helpscout.net/conversation/1347367935/215413/
Related ticket: https://secure.helpscout.net/conversation/1364738701/222493?folderId=2135277
Related ticket - https://secure.helpscout.net/conversation/1488090663/257184/
This still happens with current version 3.9.0.1, same error, but it just happened randomly, no upgrade was performing
i got the same random PHP Warning with 3.9.0.x from copy() on class-wp-filesystem-direct.php
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).
Related - https://secure.helpscout.net/conversation/1630916805/294657/
related https://secure.helpscout.net/conversation/1728379095/314505/