• 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

     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 1 day, 11 hours ago by shimist.
Viewing 15 replies - 1 through 15 (of 22 total)
  • Plugin Support Sai (woo-hc)

    (@saivutukuru)

    Hello @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

    (@shimist)

    @saivutukuru

    I disabled all plugins
    Then I tried with Twenty Twenty-Five theme
    When WooCommerce is enabled, the error occurs again

    Plugin Support Sai (woo-hc)

    (@saivutukuru)

    Thanks for the update, @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” 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:

    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

    (@shimist)

    @saivutukuru

    Thank you very much for your attention and guidance
    But I don’t see the PHP Errors tab
    But the error still occurs in the debug.log file in the wp-content folder

    Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    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/ or 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

    (@shimist)

    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 1 day, 8 hours ago by shimist.
    • This reply was modified 1 day, 8 hours ago by shimist.
    Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    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

    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/

    Thread Starter shimist

    (@shimist)

    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)

    (@shahzeenfarooq)

    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

    (@shimist)

    $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)

    (@shahzeenfarooq)

    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

    (@shimist)

    Changing to Php 8.2 did not solve the problem.

    Plugin Support LovingBro (woo-hc)

    (@lovingbro)

    Hi @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 or 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

    (@shimist)

    I found the problem
    But I don’t know how to solve it
    When 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 occurs
    Otherwise, this error does not occur anywhere else.

    Plugin Support LovingBro (woo-hc)

    (@lovingbro)

    Hi @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 22 total)

You must be logged in to reply to this topic.