WordPress – A critical bug in the popular WooCommerce plugin is causing widespread site crashes for online stores built on WordPress. The issue, which originates from a faulty line of code, is leading to fatal errors that are breaking ecommerce websites with no prior warning.
The problem was first reported on the WordPress.org support forums, where several users confirmed they were experiencing the same issue. In most cases, the sites crashed unexpectedly, even without any recent plugin updates or changes.
The error stems from a line in the BlockPatterns.php
file located at:wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.php
The fatal error message reads:Uncaught Error: strpos(): Argument #1 ($haystack) must be of type string, null given...
The bug has affected WooCommerce versions 9.8.2 and 9.8.3, and rolling back to earlier versions like 9.7.1 hasn’t resolved the issue for many users. Fortunately, a temporary workaround has been shared:
Quick Fix:
Replace line 251 in the BlockPatterns.php
file with:
phpCopyEditif ( strpos( $category['title'] ?? '', $prefix ) !== false ) {
This small edit adds a null coalescing operator (?? ''
) to prevent the error from being triggered when a null value is passed.
Users are reminded to clear all WordPress caching layers after applying the change. On platforms like WP Engine, multiple levels of caching (Page Cache, Varnish Cache) must be purged manually to see the fix take effect.
WooCommerce’s development team has acknowledged the issue and is actively working on a patch. They’ve advised users to track progress on their GitHub thread:
WooCommerce GitHub Issue #57760
They also mentioned that the source of the issue—bad cache data from the Woo pattern repository—has been addressed on their end, but some sites may still be affected until a full patch is released.
This incident highlights the importance of robust error handling and the need for quicker rollback mechanisms within WordPress plugin ecosystems, especially for mission-critical platforms like WooCommerce.