• Resolved greencode

    (@greencode)


    Not sure why this would have happened but I’ve just disabled Legacy REST API and then the site and backend got a fatal error

    [06-May-2025 12:52:26 UTC] PHP Fatal error:  Uncaught TypeError: strpos() expects parameter 1 to be string, null given in /home/mysite/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.php:251
    Stack trace:
    #0 /home/mysite/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.php(251): strpos(NULL, '_woo_')
    #1 [internal function]: Automattic\WooCommerce\Blocks\BlockPatterns->Automattic\WooCommerce\Blocks\{closure}(Array)
    #2 /home/mysite/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.php(260): array_map(Object(Closure), Array)
    #3 [internal function]: Automattic\WooCommerce\Blocks\BlockPatterns->Automattic\WooCommerce\Blocks\{closure}(Array)
    #4 /home/mysite/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.php(247): array_map(Object(Closure), Array)
    #5 /home/mysite/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.php(229): Automattic\WooCommerce\Blocks\BlockPatterns->parse_categories(Array)
    #6 /home/mysite/public_h in /home/mysite/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.php on line 251

    The only way to get it back up and working again was to replace this in this file wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.php

    if ( strpos( $category['title'], $prefix ) !== false ) {

    with this

    if ( isset( $category['title'] ) && is_string( $category['title'] ) && strpos( $category['title'], $prefix ) !== false ) {

    I was originally running WooCommerce 9.8.2 and even after i’d got everything back up and running and updated to 9.8.3 I got the same error and had to apply the same patch.

    Any ideas?

    • This topic was modified 1 year ago by greencode.
Viewing 7 replies - 16 through 22 (of 22 total)
  • Plugin Support LovingBro (woo-hc)

    (@lovingbro)

    Hi @davelo,

    Thanks for clarifying that. I completely understand your concern, especially given the issue’s unpredictability and the timing around a high-traffic sales weekend like Mother’s Day. It’s definitely unsettling when something breaks without any clear trigger, and I agree it makes planning and stability all the more critical.

    Our development team is actively investigating the root cause and working on a permanent fix. In the meantime, it’s great that the workaround has helped many users regain site access. If you haven’t already, you can keep track of updates and contribute to the discussion here: https://github.com/woocommerce/woocommerce/issues/57760

    Please feel free to check back in with any new observations, and we’ll continue to do everything we can to support you through this.

    Wishing you a smooth and successful weekend for your shop!

    Thread Starter greencode

    (@greencode)

    Hi @lovingbro Thanks for this but it’s not just sites that disable the Legacy REST API plugin as other users are reporting i.e. some users are reporting the issue after making no updates or deactivating any plugins! I’ll keep an eye on the github you linked to.

    Plugin Support LovingBro (woo-hc)

    (@lovingbro)

    Hi @greencode,

    Thank you for following up and for clarifying, and you’re absolutely right. My earlier response was intended for another user and was mistakenly addressed to you, so I appreciate your patience with that.

    Yes, we’ve seen several reports from users who encountered this fatal error without making any plugin changes or updates, so it’s clear the issue isn’t limited to disabling the Legacy REST API. It seems to stem from a broader handling issue in the block pattern logic, which our development team is now actively investigating.

    A more permanent fix is in the works, and updates will be shared directly in the GitHub thread here: https://github.com/woocommerce/woocommerce/issues/57760

    Thanks again for staying on top of this and helping others with your workaround in the meantime!

    Alje Ybanez

    (@adminalje)

    Alje Ybanez

    (@adminalje)

    Alje Ybanez

    (@adminalje)

    Plugin Support Nami

    (@woonami)

    Hello there,

    This issue should be fixed now with the dot release of 9.8.4. If there is any issue with the dot release, could you please report them in our GitHub issue?: https://github.com/woocommerce/woocommerce/issues/57760

    Thank you again for your patience and understanding with this issue.

Viewing 7 replies - 16 through 22 (of 22 total)

The topic ‘Fatal error BlockPatterns.php:251’ is closed to new replies.