A bug in WooCommerce has caused fatal errors on websites, leading to crashes. The issue originates from a specific line of code, and while a temporary solution has been provided, the WooCommerce team is working on a permanent fix.
The WooCommerce Website Crash
The issue was first reported on the WooCommerce support forum, with other users confirming they experienced the same problem. Many users mentioned that their websites suddenly crashed without any recent changes. The initial person who reported the bug shared a solution, which involved editing a line of code in the BlockPatterns.php file, a core WooCommerce file.
Users reported seeing the following fatal error message:
“Uncaught Error: strpos(): Argument #1 ($haystack) must be of type string, null given in /wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.php on line 251.”
One commenter explained:
“There’s the same problem here. This issue occurred in version 9.8.2, and upgrading to version 9.8.3 didn’t fix it. Downgrading to version 9.7.1 didn’t help either. The problem occurred without any interaction with plugins or recent updates. Replacing line 251 with new code temporarily resolves the issue. We’ll need a more stable solution until the WooCommerce team releases an official patch.”
Some users noted the error occurred after updating plugins, but rolling back the update didn’t solve the problem. Others reported no recent changes before the site crashes.
WooCommerce Team Responds
A WooCommerce support representative acknowledged the issue and confirmed that the team was aware of it. They assured users that they were actively working on a solution.
Quick Fix Available
A quick fix has been posted for affected websites:
To fix the fatal error that causes websites to go down with the error message:
“Fatal error: Uncaught TypeError: strpos(): Argument #1 ($haystack) must be of type string, null given in /wp-content/plugins/woocommerce/src/Blocks/BlockPatterns.php:251”
Users should modify line 251 in BlockPatterns.php:
After applying this fix, it’s recommended to clear any caching layers in WordPress to ensure the site functions properly.
This quick fix helps sites get back online while the WooCommerce team works on a more permanent solution.
Cache Issues on Certain Hosting Platforms
Some users reported continued issues after applying the fix, particularly with hosting platforms like WP Engine. In these cases, clearing multiple cache layers, including Page Cache and Varnish caches, was necessary to fully resolve the problem.
For users experiencing issues, restoring a backup may serve as a temporary solution until the official patch is released.
Related Topics
- Shopify VS. WordPress: Which is the Best for E-Commerce
- How to Secure Your WordPress Site from AI-Powered Malicious Plugins
- WordPress Campus Connect Expands