Super cache - fix 2 null/false warnings#32484
Conversation
This fixes the problem where $wp_cache_query_uri is not set because it's set in wp-cache-phase1.php, which is not loaded in wp-admin.
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Super Cache plugin:
|
* Disable caching if in the backend. This fixes the problem where $wp_cache_query_uri is not set because it's set in wp-cache-phase1.php, which is not loaded in wp-admin. * Make sure this permalink is a string. NULL/false will cause problems * changelog
As reported by @mcaskill in a comment on #29971 the get_permalink() function can return false which we didn't handle in the preload function. They provided a small patch to check which I added to this PR.
It was observed by @dilirity during testing that there was a NULL warning in trunk:
I noticed this only happens in wp-admin and so, this PR fixes this by disabling caching in "the backend". wp-cache-phase1.php is not loaded in wp-admin, where $wp_cache_request_uri is defined, which caused the problem. This also has the side effect of reducing the amount of extra logging done in the debug log in areas of a site that aren't cached any way.
Proposed changes:
Other information:
Jetpack product discussion
p1692102560916519-slack-C016BBAFHHS
Does this pull request change what data or activity we track or use?
No
Testing instructions:
I'm not sure how to replicate the permalink issue with preloading. It might be caused by deleting a post while preloading, when the preload system has the post_id in the "to check" array in memory.
The issue found by Peter can be replicated by using trunk, going to wp-admin and looking at the debug log.
Apply this patch and the
str_replacewarning disappears because it has not been run.