Fatal error BlockPatterns.php:251
-
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 251The 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?
- You must be logged in to reply to this topic.