Title: Fatal error BlockPatterns.php:251
Last modified: May 6, 2025

---

# Fatal error BlockPatterns.php:251

 *  Resolved [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/)
 * 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
 *     ```wp-block-code
       [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:251Stack 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
 *     ```wp-block-code
       if ( strpos( $category['title'], $prefix ) !== false ) {
       ```
   
 * with this
 *     ```wp-block-code
       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](https://wordpress.org/support/users/greencode/).

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

1 [2](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/page/2/?output_format=md)

 *  Thread Starter [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452685)
 * Edit the code here
 *     ```wp-block-code
       wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.php
       ```
   
 * Replace this
 *     ```wp-block-code
       if ( strpos( $category['title'], $prefix ) !== false ) {
       ```
   
 * with this
 *     ```wp-block-code
       if ( isset( $category['title'] ) && is_string( $category['title'] ) && strpos( $category['title'], $prefix ) !== false ) {
       ```
   
 *  [José Jefferson](https://wordpress.org/support/users/ojosejefferson/)
 * (@ojosejefferson)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452699)
 * same problem
 * Uncaught Error: strpos(): Argument #1 ($haystack) must be of type string, null
   given in /var/www/site/data/www/site.com.br/wp-content/plugins/woocommerce/src/
   Blocks/BlockPatterns.php on line 251
 *  [chunkysteveo](https://wordpress.org/support/users/chunkysteveo/)
 * (@chunkysteveo)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452709)
 * Just got the same error about an hour ago – site is down after doing no updates.
   Will try this fix to get it back up and running at least….
 * **Code solution for line 251 worked and site back up. Need resolution from Woo
   though. Checking GitHub**
    -  This reply was modified 1 year ago by [chunkysteveo](https://wordpress.org/support/users/chunkysteveo/).
 *  Thread Starter [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452713)
 * There’s a lot of people [reporting it now on GitHub](https://github.com/woocommerce/woocommerce/issues?q=is%3Aissue%20state%3Aopen%20legacy)
 *  [Francesco Campus](https://wordpress.org/support/users/codifigata/)
 * (@codifigata)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452714)
 * Same issue here.
 * It occurred in version 9.8.2, and upgrading to 9.8.3 didn’t resolve it. Downgrading
   to 9.7.1 didn’t help either.
 * The problem happened without any interaction with plugins or recent updates. 
   Replacing the code at line 251 worked as a temporary workaround.
 * We’ll need to find a more stable solution until the WooCommerce team releases
   an official patch.
 *  [Daniel van de Kamp](https://wordpress.org/support/users/dvandekamp2/)
 * (@dvandekamp2)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452716)
 * Same here. I was updating plugins, then got this error. Uploaded all the older
   versions of the plugins back, but still got this error. Chatgpt gave me the solution
   above and this works for now. But want to keep posted on more solid solutions.
 *  [Kamran Abdul Aziz](https://wordpress.org/support/users/ekamran/)
 * (@ekamran)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452719)
 * Same error, no plugin updated.
 *  [maeliacreation](https://wordpress.org/support/users/maeliacreation/)
 * (@maeliacreation)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452731)
 * Same error here after updating from WooCommerce 9.8.2 to 9.8.3.
 * The workaround is working for now.
 *  [chartnet](https://wordpress.org/support/users/chartnet/)
 * (@chartnet)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452737)
 * Same here. Even downgrading doesn’t work…
 *  [Moses M. (woo-hc)](https://wordpress.org/support/users/mosesmedh/)
 * (@mosesmedh)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452739)
 * Hi [@greencode](https://wordpress.org/support/users/greencode/), [@ekamran](https://wordpress.org/support/users/ekamran/),
   [@dvandekamp2](https://wordpress.org/support/users/dvandekamp2/), [@codifigata](https://wordpress.org/support/users/codifigata/),
   [@chunkysteveo](https://wordpress.org/support/users/chunkysteveo/),
 * Thank you for reporting this. It’s a known issue, and a temporary workaround 
   has been shared here: [https://github.com/woocommerce/woocommerce/issues/57760#issuecomment-2854510504](https://github.com/woocommerce/woocommerce/issues/57760#issuecomment-2854510504)
 * You can track progress and updates on the GitHub thread: [https://github.com/woocommerce/woocommerce/issues/57760](https://github.com/woocommerce/woocommerce/issues/57760),
   as the team is aware and actively addressing it.
 *  Thread Starter [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452749)
 * [@mosesmedh](https://wordpress.org/support/users/mosesmedh/) Thanks for the quick
   update. Looking forward to a permanent resolution.
 *  [oldlastman](https://wordpress.org/support/users/oldlastman/)
 * (@oldlastman)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452769)
 * Same error here.
 * In my case, upgrading to 9.8.3 doesn’t fix the problem.
 * I’ve applied the manual solution described here:
 * [https://github.com/woocommerce/woocommerce/issues/57760#issuecomment-2854510504](https://github.com/woocommerce/woocommerce/issues/57760#issuecomment-2854510504).
   Waiting for any official updates or comments.
 *  [Dave Loodts](https://wordpress.org/support/users/davelo/)
 * (@davelo)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452795)
 * yet, same issue. Downsizing to WooCommerce 9.7.1 made it work again.
   Bizar thing:
   nothing was going on in the site: no updates, no sale,
 *  [Jonayed (woo-hc)](https://wordpress.org/support/users/jonayedhosen/)
 * (@jonayedhosen)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/#post-18452912)
 * Hi [@davelo](https://wordpress.org/support/users/davelo/) ,
 * Just to make sure I’m understanding correctly—after downgrading the plugin version,
   the site is back up and running, but you’re not seeing any sales data showing
   up, is that right?
 *  [Dave Loodts](https://wordpress.org/support/users/davelo/)
 * (@davelo)
 * [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/page/2/#post-18452922)
 * [@jonayedhosen](https://wordpress.org/support/users/jonayedhosen/) no, that’s
   not what i meant. During the moment of outage, there was no sale or any update
   going on. The site has not much traffic.
   So, that’s the scary part of this issue.
   When and how? Seems like nobody knows. And since it’s Mother’s day this weekend,
   we need to be very very careful for some shops.

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

1 [2](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/page/2/?output_format=md)

The topic ‘Fatal error BlockPatterns.php:251’ 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/)

 * 23 replies
 * 16 participants
 * Last reply from: [Nami](https://wordpress.org/support/users/woonami/)
 * Last activity: [1 year ago](https://wordpress.org/support/topic/fatal-error-blockpatterns-php251/page/2/#post-18453405)
 * Status: resolved