How to inspect events returned from database queries?

Home Forums Calendar Products Events Calendar PRO How to inspect events returned from database queries?

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1148905
    Peter Monk
    Participant

    Hi,

    I’m doing some troubleshooting on an issue where events aren’t appearing in the mini calendar widget.
    (I’ve tried deactivating all the other plugins and that doesn’t help, so I assume it’s something in the theme, though I struggle to understand how it could possibly affect what the calendar database queries return…)

    But I’m wanting to inspect the event data structures being returned from the database in the building of the mini calendar, so I can ensure the correct events are being returned.

    Can you give me any ideas on where I can best temporarily insert trace output commands in the plugin source files to see what’s being returned from the database? Whereabouts could I get it to spit out, for example, all the events it’s going to place in the mini calendar for the displayed month before it does so?

    Thanks,
    Peter.

    #1148949
    Peter Monk
    Participant

    Hi again,

    Just as a follow up request, I would also love to know what query is being run to get the results.

    The behaviour I’m seeing is really odd.

    I had one event in July, I have three in August and two in September.
    Viewing the current month (August) in the mini cal, I see no events.
    Changing month back to July, I see my event OK.
    Moving forward to September, I see only the second of my two events.

    Throughout all this, the list of events beneath the mini cal is displaying ALL EVENTS OK.

    What I don’t get is that both the mini cal and the event list beneath it are presumably running the same queries on the same tables, so why aren’t they returning the same events?

    If there is some conflict in the theme or elsewhere, why doesn’t it have a consistent effect? Why would I get all events some months, none in other months, and only some in other months? Why isn’t affecting the list as well as the grid?

    it just seems like there is something that differentiates the events in some way that is causing the database queries to grab different results.

    So, how can I see what queries are being run on the database in each of these cases?

    Thanks very much for your help!

    Peter.

    #1149131
    Josh
    Participant

    Hey Peter,

    Thanks for reaching out to us!

    It sounds like there is definitely something odd going on here. I understand that it is most likely a long shot here on the impact of the theme, but does the issue persist with a default theme activated (just to rule that completely out from the start).

    Also, to help in follow ups here would you mind sharing your system information in a private reply.

    But, to get what you’re looking for, the widget there uses the “tribe_show_month()” function. So, you could do something like:

    
    add_action( 'tribe_events_before_show_month', 'test_month_widget_query' );
    function test_month_widget_query( $args ) {
    print_r( tribe_get_events($args) );
    }
    

    to output the results of the associated query there and test the results before they’re getting output to the widget views there.

    Let me know if this helps.

    Thanks!

    #1149313
    Peter Monk
    Participant

    This reply is private.

    #1149321
    Peter Monk
    Participant

    Hi again Josh,

    I think I’ve found the problem, and it looks like it might be some unexpected behaviour in Events Calendar.

    So, your trace output function (thanks for that, it worked great) showed that it was indeed grabbing ALL the events from the database, it just wasn’t displaying them.

    As an example, here’s a couple of them — one of which displayed, the other of which didn’t.

    Array (

    // THIS ONE DOESN’T DISPLAY
    [4] => WP_Post Object (
    [ID] => 5128
    [post_author] => 3
    [post_date] => 2016-08-08 22:48:59
    [post_date_gmt] => 2016-08-08 12:48:59
    [post_content] => Content here.
    [post_title] => Meeting
    [post_excerpt] => Excerpt content.
    [post_status] => publish
    [comment_status] => open
    [ping_status] => closed
    [post_password] =>
    [post_name] => event-4-slug
    [to_ping] =>
    [pinged] =>
    [post_modified] => 2016-08-08 23:11:33
    [post_modified_gmt] => 2016-08-08 13:11:33
    [post_content_filtered] =>
    [post_parent] => 0
    [guid] => http://xxx.com/?post_type=tribe_events&p=5128
    [menu_order] => 0
    [post_type] => tribe_events
    [post_mime_type] =>
    [comment_count] => 0
    [filter] => raw
    [EventStartDate] => 2016-09-08 08:00:00
    [EventEndDate] => 2016-09-08 10:00:00
    )
    // THIS ONE DOES DISPLAY
    [5] => WP_Post Object (
    [ID] => 5129
    [post_author] => 3
    [post_date] => 2016-08-08 22:55:02
    [post_date_gmt] => 2016-08-08 12:55:02
    [post_content] => Content here.
    [post_title] => Event title.
    [post_excerpt] => Excerpt here.
    [post_status] => publish
    [comment_status] => open
    [ping_status] => closed
    [post_password] =>
    [post_name] => event-5-slug
    [to_ping] =>
    [pinged] =>
    [post_modified] => 2016-08-08 23:11:40
    [post_modified_gmt] => 2016-08-08 13:11:40
    [post_content_filtered] =>
    [post_parent] => 0
    [guid] => http://xxx.com/?post_type=tribe_events&p=5129
    [menu_order] => 0
    [post_type] => tribe_events
    [post_mime_type] =>
    [comment_count] => 0
    [filter] => raw
    [EventStartDate] => 2016-09-09 23:00:00
    [EventEndDate] => 2016-09-10 01:00:00 )
    )

    So, the one thing I noticed was that all the events that DID display had an EventStartDate and an EventEndDate (the last two fields in the data array) on different dates. For all events that DIDN’T display, these were on the same date as each other.

    The times displayed here are not the times I set the event for, BTW — I assume they’re in GMT, as these events are in a GMT+11 time zone.

    This seemed to me to be a silly reason not to display, but I did some testing and got definite results. If I changed an event that WAS displaying so that its GMT start and end times were on the same day, it disappeared from the mini calendar. And if I changed the times for an event that WASN’T displaying so that its GMT times were on different days, it suddenly started appearing.

    So I don’t know if I have some weird settings in my plugin, or whether there’s some weird issue with the server, or whether Events Calendar is doing something it shouldn’t, but it does definitely appear to be related to dates, time zones and event selection/display based on those criteria.

    If you could investigate this and let me know what you find, I’d appreciate it!

    Cheers,
    Peter.

    #1149460
    Josh
    Participant

    Hey Peter,

    Thanks for following up with this information! I’ll do some further digging on this particular issue and will get back to you with what I find.

    Thanks!

    #1149797
    Peter Monk
    Participant

    Thanks, Josh, I appreciate it.

    Cheers,
    Peter.

    #1150464
    Josh
    Participant

    Hey Peter,

    I did some further testing here but was unable to replicate the issue you’re describing here. Switching my timezones and formats to match yours in your system information (thanks for providing) I created a few events and all of them showed whether the start or end date were on the same date or on different dates.

    As a next step, have you tried switching to a default theme to see if that changes anything here? You’re right that it would be rare for the theme to impact the query and the results returned, however it is much more likely that it could be causing some of the widget output and display issues related here.

    Let me know if that shows anything different.

    Thanks!

    #1151616
    Peter Monk
    Participant

    Hi Josh,

    I’ve found a solution. I’m wondering if it’s some kind of conflict between various timezone settings (server/WordPress/Events Calendar).

    If I change the “Timezone mode” setting on the Settings page from “Use the sitewide timezone everywhere” to “Use the local timezones for each event”, the mini calendar is fully and correctly populated.

    All the events are individually set to Sydney time (AEST), and WordPress itself is set to the Sydney timezone.
    The server itself is running on ACST (half an hour behind AEST), although the system data dump that Events Calendar produced seems to say it’s running on UTC, which it isn’t.

    I don’t know why changing the above option fixes it, because either way it should be using AEST — and if I switch on the “show timezone” option, it always displays AEST no matter what the timezone usage option is set to. But in any case, changing the above option fixes the problem.

    My only thought is that it could be something to do with a disparity between the WordPress timezone, the server timezone, and the fact that Events Calendar seems to think the server is running on UTC.

    If you need any further info, please let me know, but my problem is sorted.

    Thanks,
    Peter.

    #1152024
    Josh
    Participant

    Hey Peter,

    That is definitely odd there. I’ll do some further digging here to see if I can replicate the issue with the different settings.

    Thanks!

    #1161008
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘How to inspect events returned from database queries?’ is closed to new replies.