Bug Report: DivisionByZeroError in OrderStatus.php line 287
-
Summary
Plugin: WooCommerce Mercado Pago
Affected versions: v8.7.5, v8.7.8 (confirmed), possibly earlier versions
Severity: High
Impact: Webhook processing fails, preventing WooCommerce order notification emails from being sent
Frequency: Intermittent (affects approximately 10-15% of orders in our production environment)
DescriptionThe plugin throws a fatal
DivisionByZeroErrorwhen processing webhooks/notifications. This error causes the webhook processing script to terminate prematurely, which prevents WooCommerce from completing the order lifecycle and triggering notification emails to customers and administrators.Key observations:
- Orders are created successfully in WooCommerce
- Payment is processed correctly by Mercado Pago
- Order metadata including
_payment_methodis saved correctly - The error occurs during webhook/notification processing after order creation
- Affected orders do NOT send “New Order” emails to admin or customers
Error Details Error Message
PHP Fatal error: Uncaught DivisionByZeroError: Division by zero File: /wp-content/plugins/woocommerce-mercadopago/src/Order/OrderStatus.php Line: 287Stack Trace
Stack trace: #0 [internal function]: MercadoPago\Woocommerce\Order\OrderStatus->processRefundNotification() #1 /wp-includes/class-wp-hook.php(324): call_user_func_array() #2 /wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #3 /wp-includes/plugin.php(565): WP_Hook->do_action()Production Evidence Error Occurrence Timeline
Production error logs show 22 occurrences of this error in January 2025: Date Time (UTC) Occurrences January 8, 2025 23:01:41 1 January 16, 2025 23:12:52 1 January 17, 2025 20:05 – 21:00 Multiple (8-10) January 18, 2025 03:05:33 1 January 20, 2025 03:10:52 1 January 24, 2025 03:15:55 1 Affected Orders
We identified 10 specific orders affected by this issue: Internal ID Order Date Payment Status Email Sent Notes 19643 Jan 12, 2025 Completed NO First reported case 19644 Jan 12, 2025 Completed NO 19645 Jan 12, 2025 Completed NO 19646 Jan 13, 2025 Completed NO 19688 Jan 15, 2025 Completed NO 19689 Jan 15, 2025 Completed NO 19699 Jan 16, 2025 Completed NO 19747 Jan 18, 2025 Completed NO 19772 Jan 20, 2025 Completed NO 19887 Jan 24, 2025 Completed NO Most recent case
Common characteristics:
- All orders used Mercado Pago as payment method
- All orders were successfully created and paid
- All orders have correct
_payment_methodmetadata - None triggered “New Order” email notifications
- Dates correlate with error log timestamps
Environment Information
WordPress: 6.9
WooCommerce: 10.4.3
PHP: 8.2.29
Theme: Bricks Child Theme 1.1
Server: Production environment (Ubuntu/Nginx)Active payment plugins:
- WooCommerce Mercado Pago v8.7.5 → v8.7.8 (updated during investigation)
Reproduction Conditions
Based on our analysis, the error occurs when:
- An order is created with Mercado Pago payment method
- The order meta
CURRENCY_RATIO(accessed viaOrderMetadata::CURRENCY_RATIO) has certain values - A webhook/notification from Mercado Pago is processed
- The webhook processing reaches line 287 where a division operation is performed
Critical observation:
The error appears to be related to the handling of theCURRENCY_RATIOorder metadata, specifically at line 287 ofOrderStatus.phpwhere a division operation is performed during refund notification processing. Impact Analysis User Experience Impact- Customers complete purchases successfully
- Customers do NOT receive order confirmation emails
- Store administrators do NOT receive new order notifications
- Orders must be manually reviewed to send confirmations
Business Impact
- Customer satisfaction affected (no confirmation emails)
- Increased support workload (customers inquire about orders)
- Manual intervention required for each affected order
- Potential loss of trust in checkout process
Technical Impact
- Fatal error terminates webhook processing
- WooCommerce order lifecycle interrupted
- Order status change hooks not triggered
- Email notification system bypassed
Additional Context Why This Affects Only Some Orders
The error appears to be intermittent because it depends on the state of
CURRENCY_RATIOmetadata for each specific order. In our environment, approximately 10-15% of Mercado Pago orders are affected. Version ComparisonWe compared versions:
- v8.7.5: Error present at line 287
- v8.7.8: Error still present at line 287 (unchanged)
- Both versions have identical
OrderStatus.php(626 lines)
The issue persists across version updates, suggesting it has not yet been addressed. Diagnostic Data Order Metadata Analysis
Affected orders show the following metadata patterns:
_payment_method: woo-mercado-pago-custom (present) _payment_method_title: Mercado Pago (present) _mp_currency_ratio: [varies across affected orders] _mercadopago_payment_id: [present with valid IDs] _order_stock_reduced: yes (stock was reduced correctly) _new_order_email_sent: [absent - email was never sent]Complete Error Log Entry Example
[24-Jan-2025 03:15:55 UTC] PHP Fatal error: Uncaught DivisionByZeroError: Division by zero in /wp-content/plugins/woocommerce-mercadopago/src/Order/OrderStatus.php:287 Stack trace: #0 [internal function]: MercadoPago\Woocommerce\Order\OrderStatus->processRefundNotification() #1 /wp-includes/class-wp-hook.php(324): call_user_func_array() #2 /wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #3 /wp-includes/plugin.php(565): WP_Hook->do_action() #4 /wp-content/plugins/woocommerce-mercadopago/src/Notification/WebhookHandler.php: do_action()Workaround Currently Applied
We have NOT modified the plugin code in production. Affected orders receive manual email notifications through WooCommerce admin panel (“Resend order emails” feature). Questions for Plugin Developers
- Under what conditions should
CURRENCY_RATIOmetadata have values that could cause division by zero? - Is there a known scenario where this metadata is not properly initialized?
- Are there configuration settings in the Mercado Pago plugin that might affect
CURRENCY_RATIOvalues? - Has this issue been reported by other users?
- Is line 287 in
OrderStatus.phpexpected to handle edge cases forCURRENCY_RATIO?
Additional Information Available
We can provide:
- Complete error logs (sanitized)
- Database exports of affected order metadata (sanitized)
- Detailed webhook payloads if accessible
- Screen recordings of the issue occurring
- Direct access to staging environment for testing
Contact Information
Reporter: Roberto Garcés
Company: XpartanSys SRL
Email: [email protected]
Timezone: UTC-3 (Uruguay)
Preferred contact method: GitHub issue / EmailWe are available to provide additional diagnostic information or testing access as needed.
You must be logged in to reply to this topic.