You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When custom cancels their subscription, fatal error occurs and this appears in the error.log like this example:
CRITICAL Allowed memory size of 268435456 bytes exhausted (tried to allocate 528384 bytes) in /www/websitename/public/wp-content/plugins/woocommerce/includes/emails/class-wc-email.php on line 447
To Reproduce
Error seems to always point to line 447 or sometimes 449 of class-wc-email.php
Customer cancels subscription
They do not receive the cancellation confirmation email due to the fatal error
Expected behavior
Actual behavior
These are the lines of code triggering it. I have 256MB of memory allocated, so this should not be happening:
/**
* Get valid recipients.
*
* @return string
*/
public function get_recipient() {
$recipient = apply_filters( 'woocommerce_email_recipient_' . $this->id, $this->recipient, $this->object, $this );
THIS LINE---> $recipients = array_map( 'trim', explode( ',', $recipient ) );
$recipients = array_filter( $recipients, 'is_email' );
return implode( ', ', $recipients );
}
Product impact
WooCommerce Subscriptions
[YES] Does this issue affect WooCommerce Subscriptions? yes/no/tbc, add issue ref
Does this issue affect WooCommerce Payments? yes/no/tbc, add issue ref
Additional context
FINDINGS:
NO LONGER WORKS FOR APPENDING CUSTOMER TO CANCELLATION EMAIL...CAUSES MEMORY ERROR AND 500
BY RESULTING IN AN INFINITE LOOP APPENDING THE CUSTOMER EMAIL TO THE RECIPIENTS INFINITE TIMES:
add_filter('woocommerce_email_recipient_cancelled_subscription', 'set_customer_as_cancelled_subscription_recipient', 10, 2);
function set_customer_as_cancelled_subscription_recipient($recipient, $subscription) {
//this line makes the customer the only recipient
// return $subscription ? $subscription->get_billing_email() : $recipient;
//this appends the customer as a recipient in addition to the recipient specified in WooCommerce Email settings
if ($subscription && false === strpos($recipient, $subscription->get_billing_email())) {
// Append the customer's billing email to the existing recipient list, separated by a comma
$recipient .= ',' . $subscription->get_billing_email();
}
return $recipient;
}
```
```
-->
The text was updated successfully, but these errors were encountered:
Describe the bug
When custom cancels their subscription, fatal error occurs and this appears in the error.log like this example:
CRITICAL Allowed memory size of 268435456 bytes exhausted (tried to allocate 528384 bytes) in /www/websitename/public/wp-content/plugins/woocommerce/includes/emails/class-wc-email.php on line 447
To Reproduce
Error seems to always point to line 447 or sometimes 449 of class-wc-email.php
Expected behavior
Actual behavior
These are the lines of code triggering it. I have 256MB of memory allocated, so this should not be happening:
/**
* Get valid recipients.
*
* @return string
*/
public function get_recipient() {
$recipient = apply_filters( 'woocommerce_email_recipient_' . $this->id, $this->recipient, $this->object, $this );
THIS LINE---> $recipients = array_map( 'trim', explode( ',', $recipient ) );
$recipients = array_filter( $recipients, 'is_email' );
return implode( ', ', $recipients );
}
Product impact
WooCommerce Subscriptions
Additional context
FINDINGS:
NO LONGER WORKS FOR APPENDING CUSTOMER TO CANCELLATION EMAIL...CAUSES MEMORY ERROR AND 500
BY RESULTING IN AN INFINITE LOOP APPENDING THE CUSTOMER EMAIL TO THE RECIPIENTS INFINITE TIMES:
add_filter( 'woocommerce_subscription_status_pending-cancel', function ( $subscription ) {
$customer_email = $subscription->get_billing_email();
$wc_emails = WC()->mailer()->get_emails();
$wc_emails['WCS_Email_Cancelled_Subscription']->recipient .= ',' . $customer_email;
$wc_emails['WCS_Email_Cancelled_Subscription']->trigger( $subscription );
return $subscription;
}, 100);
THIS APPEARS TO WORK AS OF JAN 2024:
add_filter('woocommerce_email_recipient_cancelled_subscription', 'set_customer_as_cancelled_subscription_recipient', 10, 2);
function set_customer_as_cancelled_subscription_recipient($recipient, $subscription) {
//this line makes the customer the only recipient
// return $subscription ? $subscription->get_billing_email() : $recipient;
//this appends the customer as a recipient in addition to the recipient specified in WooCommerce Email settings
if ($subscription && false === strpos($recipient, $subscription->get_billing_email())) {
// Append the customer's billing email to the existing recipient list, separated by a comma
$recipient .= ',' . $subscription->get_billing_email();
}
return $recipient;
}
The text was updated successfully, but these errors were encountered: