Title: PHP Deprecated: str_contains():
Last modified: November 21, 2025

---

# PHP Deprecated: str_contains():

 *  Resolved [shimist](https://wordpress.org/support/users/shimist/)
 * (@shimist)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/)
 * The host’s php version is 8.1.
   The WordPress version is 6.8.3
 * WooCommerce 10.3.5
 * 
   But this error is shown in debug.log
 *     ```wp-block-code
        PHP Deprecated:  str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /home/***/public_html/wp-includes/shortcodes.php on line 246
       ```
   
 * I deactivated all plugins and then activated only WooCommerce
   And this error 
   turned out to be from WooCommerce.When I deactivate WooCommerce this error does
   not appear.Can you help me to solve this problem or update WooCommerce to fix
   this problem?
    -  This topic was modified 7 months ago by [shimist](https://wordpress.org/support/users/shimist/).

Viewing 15 replies - 1 through 15 (of 29 total)

1 [2](https://wordpress.org/support/topic/php-deprecated-str_contains/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/php-deprecated-str_contains/page/2/?output_format=md)

 *  [Sai (woo-hc)](https://wordpress.org/support/users/saivutukuru/)
 * (@saivutukuru)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18727473)
 * Hello [@shimist](https://wordpress.org/support/users/shimist/),
 * Thanks for sharing the details. The notice you’re seeing isn’t actually coming
   from WooCommerce itself; it’s triggered inside WordPress core, in `wp-includes/
   shortcodes.php`. WooCommerce is just calling the shortcode system, but something
   is returning a `null` value to WordPress, which leads to this deprecated warning
   on PHP 8.1.
 * Even though it stops when WooCommerce is deactivated, that usually just means
   WooCommerce is the one _using_ a shortcode at that moment, not that WooCommerce
   is causing the null value.
 * Since this involves custom code or third-party filters outside WooCommerce core,
   it isn’t something we can directly fix from our side. However, the next best 
   step is to temporarily switch to a default theme (like Twenty Twenty-Five) and
   re-enable plugins one by one to find what’s passing the `null` value.
 * If you do find a specific plugin or custom snippet involved, the developer of
   that component should be able to patch it.
 * Feel free to update us if you track down the source after running those checks.
 *  Thread Starter [shimist](https://wordpress.org/support/users/shimist/)
 * (@shimist)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18727505)
 * [@saivutukuru](https://wordpress.org/support/users/saivutukuru/)
 * I disabled all plugins
   Then I tried with Twenty Twenty-Five themeWhen WooCommerce
   is enabled, the error occurs again
 *  [Sai (woo-hc)](https://wordpress.org/support/users/saivutukuru/)
 * (@saivutukuru)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18727513)
 * Thanks for the update, [@shimist](https://wordpress.org/support/users/shimist/).
   Let’s check the full stack trace so we can see exactly where the `null` value
   is coming from:
 * **1. Install the “[Query Monitor](https://wordpress.org/plugins/query-monitor/)”
   plugin: **It’s free and very reliable. After activating it, reload the page that
   triggers the warning. You’ll find the full stack trace under **Query Monitor 
   → PHP Errors** — no file changes needed.
 * **2. Check your hosting error logs: **Many hosts already include stack traces
   in their PHP error logs. You can open these from your hosting control panel (
   often found under _Errors_, _Logs_, or _PHP Error Log_).
   The file is usually 
   named something like:
 *     ```wp-block-code
       error_log
       php-error.log 
       ```
   
 * If one of these methods gives you the full traceback, please share it here; that
   will tell us exactly which function is passing the `null` value into `str_contains()`,
   and we can guide you from there.
 *  Thread Starter [shimist](https://wordpress.org/support/users/shimist/)
 * (@shimist)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18727542)
 * [@saivutukuru](https://wordpress.org/support/users/saivutukuru/)
 * Thank you very much for your attention and guidance
   But I don’t see the PHP Errors
   tabBut the error still occurs in the debug.log file in the wp-content folder
 * ![](https://i0.wp.com/i.postimg.cc/ncvdr289/Screenshot-2025-11-21.jpg?ssl=1)
 *  Plugin Support [shahzeen(woo-hc)](https://wordpress.org/support/users/shahzeenfarooq/)
 * (@shahzeenfarooq)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18727565)
 * Hi there!
   Thank you for the update. I’ve tried to replicate the issue on my end,
   but I wasn’t able to reproduce it. For testing purposes, could you please try
   the following?Head over to **WooCommerce → Status → Tools**, and do the following:
    - WooCommerce transients – Clear
    - Expired transients – Clear
    - Clear template cache – Clear
    - Capabilities – Reset Capabilities
    - Clear customer sessions -Clear
 * If that does not work, I’d like to understand your site properly. Please share
   with us the necessary information below for us to investigate the issue further:
    - **System Status Report** which you can find via WooCommerce > Status
    - **Fatal error logs** (if any) under WooCommerce > Status > Logs.
 * Please use [https://pastebin.com/](https://pastebin.com/) or [https://gist.github.com/](https://gist.github.com/)
   and share a link to that paste in reply here. Once we have more information, 
   we’ll be able to assist you further.
 *  Thread Starter [shimist](https://wordpress.org/support/users/shimist/)
 * (@shimist)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18727577)
 *     ```wp-block-code
       Invalid limit type passed to wc_get_related_products. Expected integer, got string with value: "3"
       ```
   
 * I only see this error in the System Status Report.
 * I fixed the Invalid limit type error.
   But still the PHP error Deprecated: str_contains():
   Passing null to parameter #1 ($haystack) of type string is deprecated in /home/****/
   public_html/wp-includes/shortcodes.php on line 246 occurs
    -  This reply was modified 7 months ago by [shimist](https://wordpress.org/support/users/shimist/).
    -  This reply was modified 7 months ago by [shimist](https://wordpress.org/support/users/shimist/).
 *  Plugin Support [shahzeen(woo-hc)](https://wordpress.org/support/users/shahzeenfarooq/)
 * (@shahzeenfarooq)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18727610)
 * Hi there!
 * Regarding the error message **“Invalid limit type passed to wc_get_related_products”**,
   I can see another user experienced a similar issue, which they were able to resolve
   by running a conflict test. In their case, the issue was caused by a Divi-related
   products module. You can check their thread here:
   [https://wordpress.org/support/topic/wc_get_related_products/#post-18513247](https://wordpress.org/support/topic/wc_get_related_products/#post-18513247)
 * Regarding your previous message, just to confirm, have you tried following the
   other steps I mentioned in my earlier response?
 * Also, for testing purposes, could you please contact your hosting provider and
   ask them to change the PHP version to **8.2** to see if the same wanring message
   still appears?
 * You can also use QuickForget to safely share your system status report  which
   you can find via WooCommerce > Status >Get report . It will automatically remove
   the data after it’s viewed:
   [https://quickforget.com/](https://quickforget.com/)
 *  Thread Starter [shimist](https://wordpress.org/support/users/shimist/)
 * (@shimist)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18727725)
 * I solved this problem “Invalid limit type passed to wc_get_related_products”
   
   But still PHP Deprecated: str_contains(): problem is not solved
 *  Plugin Support [shahzeen(woo-hc)](https://wordpress.org/support/users/shahzeenfarooq/)
 * (@shahzeenfarooq)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18727744)
 * Hi there!
 * I’m glad you were able to solve the “Invalid limit type passed to wc_get_related_products”
   issue. Could you please share how you resolved it? That way, if any other users
   face a similar issue, they can benefit from your experience.
 * Regarding your previous issue, before escalating it, I just want to confirm —
   have you tried changing the PHP version to see if the **PHP Deprecated: str_contains()**
   error disappears?
 * Also, could you please share your **system status report**? In your previous 
   response, you only shared the error log, but we need the system status report,
   which you can find via **WooCommerce → Status → Get report**.
 *  Thread Starter [shimist](https://wordpress.org/support/users/shimist/)
 * (@shimist)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18727782)
 *     ```wp-block-code
       $args['posts_per_page'] =  tie_get_option( 'related_products_number', $columns );change to $args['posts_per_page'] = (int) tie_get_option( 'related_products_number', $columns );
       ```
   
 * For PHP Deprecated error: str_contains(): Are you saying I should change php 
   to 8.2 or 8.3?
 *  Plugin Support [shahzeen(woo-hc)](https://wordpress.org/support/users/shahzeenfarooq/)
 * (@shahzeenfarooq)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18727796)
 * Hi there!
 * Yes, please try changing the PHP version to **8.2 or 8.3**. Also, you can try**
   rolling back WooCommerce to the previous version** and then updating the plugin
   again to see if that resolves the issue.
 * Additionally, to escalate your issue, we will need your **site system status 
   report**. Could you please share that as well?
 *  Thread Starter [shimist](https://wordpress.org/support/users/shimist/)
 * (@shimist)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18728014)
 * Changing to Php 8.2 did not solve the problem.
 *  [LovingBro (woo-hc)](https://wordpress.org/support/users/lovingbro/)
 * (@lovingbro)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18728031)
 * Hi [@shimist](https://wordpress.org/support/users/shimist/), I understand how
   persistent issues like this can feel, especially when you have already tested
   different PHP versions and resolved the related products limit warning. I appreciate
   the steps you have taken so far and I am here to help you get to the root of 
   this deprecated notice.
 * Since the PHP Deprecated notice is coming directly from WordPress core and WooCommerce
   is simply triggering shortcode parsing, the most important thing now is to identify
   what is returning a null value during shortcode handling.
 * To move forward, I will need to confirm a few more details from your setup. Can
   you please share your full System Status Report using either [https://pastebin.com](https://pastebin.com/)
   or [https://gist.github.com](https://gist.github.com/) so I can review the environment
   more closely. You can get this from WooCommerce then Status then Get system report.
   If you have WooCommerce logs enabled under WooCommerce then Status then Logs,
   please also share any relevant entries there.
 * Once I can see the full environment, I will be able to guide you more accurately
   on what is passing the unexpected null value into the shortcode handler.
 *  Thread Starter [shimist](https://wordpress.org/support/users/shimist/)
 * (@shimist)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18728186)
 * I found the problem
   But I don’t know how to solve itWhen I enable WooCommerce
   widgets including **class-wc-widget-recently-viewed.php** and **class-wc-widget-
   products**.**php** and then click on the product link that shows in those widgets,
   that error occursOtherwise, this error does not occur anywhere else.
 *  [LovingBro (woo-hc)](https://wordpress.org/support/users/lovingbro/)
 * (@lovingbro)
 * [7 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/#post-18728193)
 * Hi [@shimist](https://wordpress.org/support/users/shimist/), thank you for the
   update. It is really helpful to know that the behaviour only appears when the
   WooCommerce widgets for recently viewed products and products are enabled, and
   that clicking the product link inside those widgets triggers the deprecated notice.
   That gives us a much clearer direction to investigate.
 * To understand this properly, can you confirm whether these are the default WooCommerce
   widgets or if they come from a custom plugin or theme code. If they are the default
   widgets, please let me know exactly which widget you enabled when the issue occurs
   so I can narrow this down further.
 * As mentioned earlier, please also share your full System Status Report using 
   pastebin.com or gist.github.com so I can review the full environment and guide
   you more accurately.
 * Looking forward to your update, let’s see how it goes.

Viewing 15 replies - 1 through 15 (of 29 total)

1 [2](https://wordpress.org/support/topic/php-deprecated-str_contains/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/php-deprecated-str_contains/page/2/?output_format=md)

The topic ‘PHP Deprecated: str_contains():’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 29 replies
 * 7 participants
 * Last reply from: [Feten L. a11n](https://wordpress.org/support/users/fetenlakhal/)
 * Last activity: [6 months ago](https://wordpress.org/support/topic/php-deprecated-str_contains/page/2/#post-18766457)
 * Status: resolved