Group Emails Stopped after WordPress release 6.5.4 | June 5, 2024
-
We are using BuddyPress Group Email Subscription plugin from last 2 Years. Everything working fine with Group Emails but after WordPress release 6.5.4 | June 5, 2024 Group Emails are stopped. There is no change in website plugins or themes.
All the environment is the same & all the plugins & themes are up to date.
The page I need help with: [log in to see the link]
-
we are seeing the same issue. with the ability for people to select the frequency of email notifications not working in groups.
Hi @boonebgorges, I have recently noticed something strange and think the problem is also related to the June update.
About 3 weeks ago we noticed not all Group Update emails were being sent to everyone in the group. After some digging I had to roll my php version back to 7.4 (was on 8.1) and now it appears new Group Updates are being sent to everyone correctly.
However, trying to track back to work out when the problem started I notice there are 1000+immediate
items in thewp_bpges_queued_items
table with the oldest dating back to2024-06-14 17:38:21
the newest date is prior to the php rollback.Looking in View queued digest items (/?sum=1) I don’t see anything.
Is the items in
wp_bpges_queued_items
stuck emails? If yes, I am guessing it would be logical to empty this table rather than sending what would likely be very confusing emails?Any advise or suggestion greatly received — also happy to do any checking/testing.
Regards,
DavidHi @davinian – Thanks for the post. I’m afraid I don’t have a good idea of why there would be problems with email sending and PHP 8.1. I have a number of client sites running this version of PHP and they haven’t experienced problems. So there must be some more complex interactions happening.
Is the items in?
wp_bpges_queued_items
?stuck emails? If yes, I am guessing it would be logical to empty this table rather than sending what would likely be very confusing emails?Correct. These are unsent immediate notifications, and it probably makes sense to clear them out. (BPGES has a failsafe mechanism that prevents this kind of “stale” notification from being sent, but you can safely delete them in any case.)
As for the underlying problem, I guess the place to start is with https://github.com/boonebgorges/buddypress-group-email-subscription/wiki/How-to-troubleshoot-missing-emails. Specifically, it would be helpful to know whether any entries are left in the log for the failed immediate emails. It would also be helpful to know whether there are server error log notices. I realize this is difficult given that you’ve rolled back your version of PHP, but perhaps you’ve got a dev or testing site where you can run some of these diagnostics.
Thanks @boonebgorges
Found your troubleshooting notes earlier and have enabled logging so will see what happens.
I suspect the underlying issue may have been another ‘older’ BuddyPress plugin that doesn’t like PHP 8.1 — will do some more testing and see if I can work out what happened — but at the moment everything is working on PHP 7.4.
Regarding
wp_bpges_queued_items
thanks for clarification, I will clear the old items and monitor.
Kind regards,
David- This reply was modified 1 month ago by davinian.
Following up on this, I have identified the problem, and have a couple of question which I am hoping you can answer ??
SoI updated a group with 226 members this afternoon, bpges-debug.log containsBeginning batch of immediate notifications for 572
and no errors, but checking my email logs (I use Brevo) I notice only 96 emails were actually sent. Looking inwp_bpges_queued_items
I can see the other 130 are stuck.Digging in the server logs there is nothing obvious until I checked the php error log and found
script '/var/www/mywebsite.tld/htdocs/wp-admin/admin-ajax.php' (request: "POST /wp-admin/admin-ajax.php?action=wp_bpges_send_queue&nonce=582010d750") execution timed out (68.861109 sec), terminating
— so my php is timing out for the process.I know I could increase the php timeout, but searching online I think it would be better to use something to batch/queue emails — one suggestion is GD Mail Queue plugin, but I wonder if there is a way to force BPGES to send in batches or if you have any other suggestions?
One last thing, is there a way to trigger and send the stuck emails in
wp_bpges_queued_items
from the last group update earlier today?Kind regards,
David- This reply was modified 1 month ago by davinian.
@davinian Thanks for the updates.
so my php is timing out for the process.
Gotcha. BPGES has a mechanism built in that is meant to detect when a system is running out of memory or is approaching the max execution time. When that happens, it’s supposed to stop running the current batch and initiate a new one. But in certain cases, this doesn’t work right. If I had a clearer idea of why it sometimes breaks, I could try to improve the logic in the plugin. See https://github.com/boonebgorges/buddypress-group-email-subscription/blob/d961f5cc0d6c3fc4b22ca47b4d66a11b1e7c1807/classes/class-bpges-async-request-send-queue.php#L244. Barring a general solution, it would be good if specific installations could set a ceiling on the number of items sent in a batch. In the future, I’d like this to be easy to do; see https://github.com/boonebgorges/buddypress-group-email-subscription/issues/237 In the meantime, there are ways to patch it together. Something like this:
add_filter(
'wp_bpges_send_queue_time_exceeded',
function( $exceeded ) {
static $counter;
if ( $counter > 50 ) { // or whatever
return true;
}
++$counter;
return $exceeded;
}
);In this way, you can trick the plugin into sending only 50 items in a batch.
one suggestion is?GD Mail Queue?plugin,
I doubt that any plugin like this would work with BPGES, given the way we send emails. You certainly could give it a try.
One last thing, is there a way to trigger and send the stuck emails in?
wp_bpges_queued_items
?from the last group update earlier today?I’m afraid I don’t have a tool for this built in. You could use code like the following to make it happen:
add_action(
'admin_init',
function() {
if ( empty( $_GET['bpges-init-batch'] ) ) {
return;
}
$activity_id = (int) $_GET['bpges-init-batch'];
bpges_send_queue()->data(
[
'type' => 'immediate',
'activity_id' => $activity->id,
]
)->dispatch();
}
);Then visit
example.com/wp-admin/?bpges-init-batch=12345
, where12345
is the activity ID you want to trigger. This is untested, but it ought to work. You’ll probably want to comment out or remove this code once it’s been used.Many thanks for the follow-up and comment on Github.
I tried the bpges-init-batch snippet but nothing happened, emails stayed stuck in the
wp_bpges_queued_items
table. bpges-debug.log didn’t show anything which I suspect is correct as the snippet doesn’t handle errors, so I enabled WP Debug and found the following in debug.log[30-Oct-2024 07:54:15 UTC] PHP Notice: Undefined variable: activity in /var/www/mysite.tld/htdocs/wp-content/themes/mytheme/functions.php on line 426
Line 426 =
'activity_id' => $activity->id,
After talking to the client they decided not to send the emails after all ?? so I flushed the
wp_bpges_queued_items
table — but I am guessing it might be good to find a fix for this as other people might find it useful?Regarding the snippet to override the number of emails batched by BPGES, I have found the GD Mail Queue plugin (when setup correctly) will intercept all emails sent from WP and BP and queue them in batches of X (50 in my case) — so far all tests with group updates are now working as expected and batches of 50 emails are sent out every 5 mins via GD Mail Queue.
If you need me to test anything or if you have any questions, please let me know, as I do have a dev site with stuck emails.
Regards,
David
- You must be logged in to reply to this topic.