Title: PHP Deprecated: str_replace(): Passing null
Last modified: August 25, 2023

---

# PHP Deprecated: str_replace(): Passing null

 *  Resolved [RichTWebGuy](https://wordpress.org/support/users/richtwebguy/)
 * (@richtwebguy)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/)
 *     ```wp-block-code
       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
       ```
   

Viewing 13 replies - 1 through 13 (of 13 total)

 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16980592)
 * If you update to 1.10.0 this warning should be gone.
 *  [sheriffdonnerknall](https://wordpress.org/support/users/sheriffdonnerknall/)
 * (@sheriffdonnerknall)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16984923)
 * 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**
 *  Thread Starter [RichTWebGuy](https://wordpress.org/support/users/richtwebguy/)
 * (@richtwebguy)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16987368)
 * I agree with [@sheriffdonnerknall](https://wordpress.org/support/users/sheriffdonnerknall/),
   problem is with str_replace. The $URL is null, because $wp_cache_request_uri 
   is null.
 *     ```wp-block-code
       if ( ! $url ) {
           $url = $wp_cache_request_uri;
       }
       ```
   
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16987373)
 * [@sheriffdonnerknall](https://wordpress.org/support/users/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?
 *  Thread Starter [RichTWebGuy](https://wordpress.org/support/users/richtwebguy/)
 * (@richtwebguy)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16987394)
 * I can’t speak for [@sheriffdonnerknall](https://wordpress.org/support/users/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?
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16987511)
 * [@richtwebguy](https://wordpress.org/support/users/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](https://github.com/Automattic/jetpack/pull/32484)
   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.
 *  [sheriffdonnerknall](https://wordpress.org/support/users/sheriffdonnerknall/)
 * (@sheriffdonnerknall)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16987794)
 * [@donncha](https://wordpress.org/support/users/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.
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16988124)
 * [@sheriffdonnerknall](https://wordpress.org/support/users/sheriffdonnerknall/)
   what page caused the warning to show?
 *  [sheriffdonnerknall](https://wordpress.org/support/users/sheriffdonnerknall/)
 * (@sheriffdonnerknall)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16988786)
 * 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.
 *  [JackSim](https://wordpress.org/support/users/jacksim/)
 * (@jacksim)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16989614)
 * I can confirm what [@sheriffdonnerknall](https://wordpress.org/support/users/sheriffdonnerknall/)
   is seeing, I posted a [report](https://github.com/Automattic/jetpack/pull/32453#issuecomment-1683783735)
   on the original PR, which is not the best way to do it, I realize now.
 * Glad to see it’s already being addressed.
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16992138)
 * Ah, I figured it out. The warning only shows if you have disabled caching for
   logged in users.
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16992754)
 * 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.
 * [https://github.com/Automattic/jetpack/pull/32629](https://github.com/Automattic/jetpack/pull/32629)
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16994198)
 * 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.

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘PHP Deprecated: str_replace(): Passing null’ is closed to new replies.

 * ![](https://ps.w.org/wp-super-cache/assets/icon-256x256.png?rev=3506220)
 * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-super-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-super-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-super-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-super-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-super-cache/reviews/)

 * 13 replies
 * 6 participants
 * Last reply from: [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/php-deprecated-str_replace-passing-null/#post-16994198)
 * Status: resolved