PHP Deprecated: str_replace(): Passing null
-
PHP Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in .../plugins/wp-super-cache/wp-cache-phase2.php on line 54
-
If you update to 1.10.0 this warning should be gone.
My site is already on WP Supercache 1.10.0 and I get the following errors:
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in […]/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 54
Warning: Cannot modify header information – headers already sent by (output started at /homepages/41/d780229698/htdocs/clickandbuilds/FreiwilligeFeuerwehrEutingenimGu/wp-content/plugins/wp-super-cache/wp-cache-phase2.php:54) in […]/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 1539
I agree with @sheriffdonnerknall, problem is with str_replace. The $URL is null, because $wp_cache_request_uri is null.
if ( ! $url ) { $url = $wp_cache_request_uri; }@sheriffdonnerknall – you should disable “display errors” on your site. That reveals information to site visitors!
What sort of URL caused that warning to show? Was it in wp-admin?
I can’t speak for @sheriffdonnerknall, but I’m running on a development server and want “display errors” On.
My question is: are you running with “display errors” when doing your testing?
@richtwebguy no, we keep an eye on the php error_log when developing, so it’s much the same thing, but doesn’t mess up the screen.
We were aware of the problem on line 54. I thought this PR would fix it because I was only able to replicate it in wp-admin, but obviously not. We’ll get it fixed in the next release.
@donncha sure, display errors should be false for a production site. However, I have enabled it on my test site that replicates the production site but is not publicly accessible.
@sheriffdonnerknall what page caused the warning to show?
I checked it: It’s displayed only for logged in users in the frontend. It does not appear for logged out users nor in the backend.
I can confirm what @sheriffdonnerknall is seeing, I posted a report on the original PR, which is not the best way to do it, I realize now.
Glad to see it’s already being addressed.
Ah, I figured it out. The warning only shows if you have disabled caching for logged in users.
This PR should fix it. I moved the code that defines the offending variable up, so it always runs.
You can do the same by moving the code on your own site from around line 147 in wp-cache-phase1.php to line 97.
Patch has been reviewed and merged. Thanks for the help.
It will be in the next release, but I don’t know when that will be.
The topic ‘PHP Deprecated: str_replace(): Passing null’ is closed to new replies.