WordPress WooCommerce Bug Triggering Site Crashes
The WooCommerce team has identified a fatal error affecting ecommerce sites and is working on a permanent fix.
A bug in WordPress is causing WooCommerce sites to crash, displaying a fatal error due to a single line of code. While a workaround is available, the WooCommerce team is actively working on a patch to resolve the issue permanently.
WooCommerce Sites Crashing
Users have reported issues with WooCommerce sites crashing on the WordPress.org support forums, with others confirming they’re experiencing the same problem. Many of these users stated that their sites crashed unexpectedly, with no recent changes made.
The initial poster shared a workaround to get sites back online. The solution temporarily resolves the issue by editing a single line of code in the BlockPatterns.php file, a key WooCommerce file.
WooCommerce Sites Crashing – Issue Details and Workaround
The issue causing WooCommerce sites to crash is traced to a bug in the BlockPatterns.php file, located here:
wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.php
Many users have reported receiving the following fatal error message:
“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.”
A commenter in the discussion shared their experience:
“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.”
Others also mentioned that updating plugins triggered the error, but rolling back the updates did not fix the issue. Some users reported no recent changes prior to the crash.
WooCommerce support has acknowledged the issue and confirmed that the team is actively working on a solution. They shared this response:
“Thank you for reporting this. It’s a known issue, and a temporary workaround has been shared here: GitHub Workaround. You can track progress and updates on the GitHub thread: GitHub Issue, as the team is aware and actively addressing it.”
Quick Fix Posted on GitHub Discussion for WooCommerce Site Crashes
A quick fix has been shared in the official WooCommerce GitHub repository to address the fatal error affecting WooCommerce sites:
If Your Websites Are Currently Down – Here’s the Quick Fix:
If your site is showing the error message:
Fatal error: Uncaught TypeError: strpos(): Argument #1 ($haystack) must be of type string, null given in /var/www/html/wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.php:251
You can resolve the issue temporarily by editing line 251 of the BlockPatterns.php file. Modify the line as follows:
php
CopyEdit
if ( strpos( $category[‘title’] ?? ”, $prefix ) !== false ) {
Make sure to clear any WordPress caching layers after applying the fix.
This workaround will help get your site back online while buying some time for the WooCommerce team to finalize the official patch for issue #57759.
Additionally, WooCommerce has noted on the GitHub repository:
“Some sites might see a fatal error around class BlockPatterns.php, with the website not loading. This was due to a bad response from the Woo pattern repository. A fix was deployed to the repository, but certain sites may still have a cached bad value.”
“The issue has been resolved at the cache source, but some sites still retain a bad cached value. Patch updates will be released to address this.”
Partner with our Digital Marketing Agency
Ask Engage Coders to create a comprehensive and inclusive digital marketing plan that takes your business to new heights.
Contact Us
Additional Issue Reported on WP Engine
A user reported continued issues on WP Engine even after applying the suggested fix:
“I’m struggling to implement the fix on WP Engine. I assume it’s a cache issue, but uploading the fix and clearing all caches isn’t working. Is there an additional step that I’m missing? So far, only restoring a backup has fixed it.”
This suggests that on some managed hosting platforms like WP Engine, standard cache-clearing may not be enough, and additional troubleshooting steps—or restoring from a backup—might be required.