• Resolved Kuldeep Baghel

    (@kuldeep-baghel)


    Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in?/var/www/html/stuffrentals/wp-content/plugins/woocommerce/includes/wc-page-functions.php?on line?139

    This error showing for many PHP function in PHP8.1

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @kuldeep-baghel

    Thanks for reaching out!

    I understand that you are encountering a deprecated warning message in PHP 8.1 related to the strstr() function in the WooCommerce plugin.

    The warning message you are seeing is due to a change in PHP 8.1 that deprecates passing a null value for the $haystack parameter in the strstr() function. This means that the code in the WooCommerce plugin needs to be updated to ensure compatibility with PHP 8.1.

    For us to investigate this further, can you please try to switch to the default Storefront theme and only WooCommerce plugin is enabled and see if this works?

    If so, then this kind of problem is usually caused by your theme or a third-party plugin present on your site. We can run a conflict test to verify this. I’d recommend cloning your site to a staging environment and performing the tests described on this guide without modifying your live site or impacting customers. Many hosts provide staging facilities, so it’s worth checking in with them. It’s also possible to do it using the free WP Staging plugin.

    If this was caused by a third-party plugin present on your site, it would be best to reach out to the developers for further assistance here.

    If this did not resolve the issue, please share your System Status Report, that will help us further troubleshoot.

    You can find it via WooCommerce > Status. Select Get system report and then Copy for support. Once you’ve done that, you can paste it into your reply here.

    If you could also provide the fatal error logs (if any) under WooCommerce > Status > Logs.

    You could copy and paste your reply here or paste it via https://gist.github.com/ and send the link here.

    Let us know how it goes!

    Hello,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.

    Thanks.

    Hi, I’ve just had the same error and found this comment searching for help.

    It’s a PHP error. I had to change the php version to 8.0 for the error to disappear.

    So this is the code from the wc-page-functions.php file that is referenced in the error.

    $path = wp_parse_url( $item->url, PHP_URL_PATH );
    $query = wp_parse_url( $item->url, PHP_URL_QUERY );
    if ( strstr( $path, $customer_logout ) || strstr( $query, $customer_logout ) ) {
    unset( $items[ $key ] );
    }

    This is a core file. How can this be a problem with a plugin other than if $item->url is not defined corectly by a plugin? Why not just change line 139 to this:

    if ( (!is_null( $path ) && strstr( $path, $customer_logout ) ) || ( !is_null( $query ) && strstr( $query, $customer_logout ) ) ) {

    This checks the first parameter in each case of strstr, $path in the first case, and $query in the second, to see if it is null prior to checking with strstr. I did this on my setup and that fixed the error

    Yes, agreed @dbemowsk. My error logs are being polluted by thousands of entries strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in woocommerce/includes/wc-page-functions.php on line 139

    Same problem here. Any fix from the Woocommerce team in the near future?

    • This reply was modified 1 year, 8 months ago by newshop.
    Saif

    (@babylon1999)

    Hey everyone,

    Just to let you know, this is merely a deprecation notice and it shouldn’t cause any disruption to your site. The developers have been actively keeping an eye on this issue through multiple reports. Hopefully, you won’t be seeing these errors in WooCommerce 7.9.0.

    Here’s the latest comment for context: https://github.com/woocommerce/woocommerce/issues/33808#issuecomment-1584809854

    Since this thread is closed, please create a new one if you have any other questions. :?)

    CC: @ablears @newshop @ablears @dbemowsk @soccerwidow
    Cheers!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Deprecated: strstr(): Passing null to parameter’ is closed to new replies.