Support

Home Forums Event Espresso Premium RE: Automated Upcoming Event Notification Messages Only Generate for Some Events

RE: Automated Upcoming Event Notification Messages Only Generate for Some Events

Posted: December 16, 2022 at 1:28 pm


tfkcc

December 16, 2022 at 1:28 pm

Followup to this thread originally posted:

https://eventespresso.com/topic/automated-upcoming-event-notification-messages-only-generate-for-some-events/

So again, we have cron disabled, but we run it manually via a curl call every 15 minutes via a Linux cron job. Will that work for upcoming event notifications or not? Clearly, it works for some, as I can see that some reminder emails are being generated and sent.

What happens when a transaction contains multiple registrations to multiple events on different days and times? Will each registration generate an upcoming reminder email, or only for the first event in that list of registrations?

I can’t figure out why some upcoming notification messages aren’t generated while others are despite the events being configured properly to use the correct automated upcoming event template.

If we set “Generate and send all messages:” to “On the same request”, will the automated upcoming event notification plugin still work? I’m guessing it won’t?

So yes, the inefficient way cron is run via WordPress is disabled, but we run it manually every 15 minutes. It appears to me this should work, as there’s a 30 minute flex window for the queue generation of messages for upcoming?


tfkcc

December 16, 2022 at 4:21 pm

I was looking into this further, and it looks like one of the problems is with the command handler itself?

UpcomingEventNotificationsCommandHandler.php line 198:

date(EE_Datetime_Field::mysql_timestamp_format, $this->getStartTimeForQuery()),
date(EE_Datetime_Field::mysql_timestamp_format, $this->getEndTimeForQuery($settings, $context)),

When the date function is called, it converts the UTC GMT time back to local time, but event start datetimes are stroed in UTC in the database…

Isn’t this a problem that would cause some events to be missed by automated upcoming event notifications?


Tony

  • Support Staff

December 20, 2022 at 7:27 am

Hi there,

So I’ll address your question related to the code first:

When the date function is called, it converts the UTC GMT time back to local time, but event start datetimes are stroed in UTC in the database…

No, it wouldn’t cause the query to ‘miss’ events, what it could do is shift the time for that query but they still wouldn’t be missed. As long as the above conversion happens with every query it will shift the times in which the query would pull the events in but still trigger for them.

Here is getStartTimeForQuery():

return time();

Now, getEndTimeForQuery():

return $this->getStartTimeForQuery()
               + (DAY_IN_SECONDS * $settings->currentThreshold($context))
               + $this->cron_frequency_buffer;

So that’s basically saying the current time + X days (set in the template) + cron_buffer

The buffer for upcoming queries is set to use a default of ‘Every 3 hours’, then we add on 30mins to that just in case someone has changed the above to be 0 (its filtered) and we need a value.

So for the above the start value output by date would be something like:

2022-12-20 14:04:51

End:

2022-12-21 17:34:51

(That is with a threshold of 1 day and default buffer)

We use the buffer because we can’t rely on WP_CRON to be consistent enough to say for sure it will trigger the messages on the day it should, so we extend the query to allow for that. However, your setup with using an actual cron removes that inconsistency, it runs every 15 mins so even with the conversion the query would run and trigger the notifications.

Now I’ll move on to your other questions:

What happens when a transaction contains multiple registrations to multiple events on different days and times? Will each registration generate an upcoming reminder email, or only for the first event in that list of registrations?

Which message type are you using for these?

The upcoming Event notification will trigger emails for the first DateTime in an event only.

The upcoming Datetime notification triggers registrations for each Datetime.

The query looks for registrations related to either the Event or Datetimes, it does not care about group registrations etc. It pulls in the registrations related to events based on the first DateTimes start date.

The Datetime notification pulls in all the datetimes based on the start date and loops over each of those DateTimes to trigger notifications linked to those DateTimes, again it’s not looking for registrations in groups etc, it just pulls in the registrations related to the current DateTime using the DTT_ID value.

For each of those, it then sets an extra meta value in the Database to say that the Upcoming notifications have been process for it and the query then skips those next time.

If we set “Generate and send all messages:” to “On the same request”, will the automated upcoming event notification plugin still work? I’m guessing it won’t?

No, the AUEN notifications will not work without that option, but I don’t think changing that setting is going to fix anything here either way.

So yes, the inefficient way cron is run via WordPress is disabled, but we run it manually every 15 minutes. It appears to me this should work, as there’s a 30 minute flex window for the queue generation of messages for upcoming?

Using a real cron is absolutely fine, we can’t rely on it because many people can’t/won’t set them up which is why we use WP_CRON and advanced users can option to do the above.


tfkcc

December 20, 2022 at 6:34 pm

Thanks for the detailed explanation. That was my understanding as well, but considering we create separate events with a single date time, I don’t understand why some reminder emails are skipped for some of our events. They just never are generated or queued in the message system… We have the same event happen during multiple dates and times, but we create separate event entries when that happens.

Still have not found out why some are skipped and out of ideas as to where to look.


tfkcc

December 20, 2022 at 7:19 pm

For each of those, it then sets an extra meta value in the Database to say that the Upcoming notifications have been process for it and the query then skips those next time.

^^ Where should I look to see this?

If an automated upcoming event notification failed to generate the message or failed for some reason, would it be logged anywhere? Working with post ID, how would see if there are any failed messages for that event?


tfkcc

December 20, 2022 at 7:35 pm

Anything else helpful you can think of I should look at to try to track this down further?


tfkcc

December 20, 2022 at 8:07 pm

Ok, so I dug into this some more, and I can see the following:

SELECT * FROM wpme_esp_extra_meta WHERE EXM_key LIKE ‘%ee_auen_processed%’ AND (OBJ_ID = ‘81423’ or OBJ_ID =’81424′) ORDER BY EXM_ID DESC

For 81424, the EXM_value column is set to NULL.
For 81423, the EXM_value column is set to empty string?

81423 had no notification emails sent out while 81424 did.

So, from that, it looks like the events that successfully processed the upcoming event notification can be seen as follows:

SELECT * FROM wpme_esp_extra_meta WHERE EXM_key LIKE ‘%ee_auen_processed%’ AND EXM_value is NULL ORDER BY wpme_esp_extra_meta.EXM_ID DESC

post id is OBJ_ID… so then, the question remains, why was 81423 skipped? It’s start date was 8.5 hours after 81424, and it’s configured the same way to use the same notification email and threshold…


tfkcc

December 20, 2022 at 8:11 pm

Does this notification process use a lot of RAM and execution time? I have limited the max memory wordpress can use (256MB / 512MB) and max input variables (3000) in the php.ini etc… wondering if any of that may cause an issue…

I did see there’s a batching option, which I’m going to give a try and set to 5 rather than 150:

`
function tw_ee_change_message_batching_automated_upcoming_event_notifications_count_eric() {
return 5;
}
add_filter( ‘FHEE__EventEspresso_AutomatedUpcomingEventNotifications_domain_services_commands_message_UpcomingNotificationsCommandHandler__getRegistrationBatchThreshold’, ‘tw_ee_change_message_batching_automated_upcoming_event_notifications_count_eric’);
`

Not sure if that will help, but I cannot figure out why some of these items are skipped. When running the event handler SQL query manually, all seemed ok, so I really don’t get it! 🙁


Tony

  • Support Staff

December 22, 2022 at 8:40 am

Does this notification process use a lot of RAM and execution time?

It depends on how many registrations it need to process at once.

How many registrations are on these events?

I did see there’s a batching option, which I’m going to give a try and set to 5 rather than 150:

That’s a REALLY low number for batching, maybe 50?

Not sure if that will help, but I cannot figure out why some of these items are skipped. When running the event handler SQL query manually, all seemed ok, so I really don’t get it!

Yeah, this is an odd issue and its going to be tricky to troubleshoot, especially with no errors to work from.

To clarify, which SQL query are you referring to above?

I assume in the message queue you don’t see any failed or waiting to generate/send messages for these events right? It sounds like you’ve checked this already from the above but I’m just double-checking.


tfkcc

December 22, 2022 at 12:30 pm

I figured it out. I’m so sorry to have bothered you over this since it’s my fault.

In the _duplicate_event function in ee-core, I had modified the duplicate event function to also duplicate the postmeta and esp_extra_meta values from the original event that is cloned. This maintained some custom meta attributes that are annoying to set / reset and also kept the waitlist settings from the original event.

However, it had the unintentional side-effect of also cloning the flag that claims the automated upcoming email notifications had already been processed.

So, basically, I changed my queries to grab only the specific keys I want to duplicate to prevent this issue moving forward:

$post_meta_infos = $wpdb->get_results(“SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$origID AND meta_key IN (‘attribute_link_to_class_details_page’)”);
$sqlClone = “SELECT EXM_type, EXM_key, EXM_value FROM ” . $wpdb->prefix . “esp_extra_meta WHERE OBJ_ID=$origID AND EXM_key IN (‘ee_wait_list_auto_promote’, ‘ee_wait_list_spaces’, ‘ee_wait_list_manual_control_spaces’)”;

Sorry about that. There is no issue with the upcoming event notification code!


Tony

  • Support Staff

December 22, 2022 at 2:31 pm

Oh, nice sleuthing and nice find!

I’m glad you figured it out 🙂

The support post ‘RE: Automated Upcoming Event Notification Messages Only Generate for Some Events’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso