woocommerce / woocommerce-square

Square POS and Payments Integration
https://woo.com/products/square
Other
10 stars 4 forks source link

Reports of "class 'WooCommerce\Square\Gateway\Blocks_Handler' not found" fatal errors #135

Closed mattallan closed 4 months ago

mattallan commented 4 months ago

Describe the bug

We've received internal reports of some sites we manage getting the following fatal error:

PHP Fatal error:  Uncaught Error: Class "WooCommerce\Square\Gateway\Blocks_Handler" not found
in .../plugins/woocommerce-square/woocommerce-square.php:430

After looking into this, I found that we're init'ing our blocks handler code and our autoloader behind two different conditions, which results in cases where register_payment_method_block_integrations() is trying to call new WooCommerce\Square\Gateway\Blocks_Handler() without our autoloader existing.

For instance:

What this difference means is if a store has WooCommerce 8.6 installed (an unsupported version), the autoloader won't be init'ed, however, the block handler code will still try to register our block integration classes resulting in the fatal error.

To reproduce

  1. Install and activate WooCommerce 8.6 and the latest WooCommerce Square
  2. Load any WP Admin page
  3. Note the fatal error: image

Environment (please complete the following information):

Additional details

System status ``` ```
shameemreza commented 4 months ago

Another report here: 8261040-zen Thread: https://wordpress.org/support/topic/critical-error-when-activating-plugin-4/