Super Cache: fix PHP warning about NULL used in str_replace#32629
Super Cache: fix PHP warning about NULL used in str_replace#32629
Conversation
Also sanitize it ASAP, just in case.
|
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:
|
haqadn
left a comment
There was a problem hiding this comment.
Tested and it works nice 👍🏼
If you disabled caching for logged in users then a warning about about using NULL showed in the PHP error log:
In this PR the code that defines $wp_cache_request_uri is moved up in wp-cache-phase1.php so it always runs. It wouldn't run if caching was disabled for logged in users due to the way checks were done.
Later on when that variable was used, functions received the value "NULL" and in the latest versions of PHP8 that caused a warning to show.
The linter complained the value was unsanitized but this code executes before WordPress is entirely loaded. It is eventually unslashed and sanitized in wp_cache_postload().
Related thread: https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/
Proposed changes:
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
No
Testing instructions: