WordPress.org

Ready to get started?Download WordPress

Forums

The Events Calendar
[resolved] Events Calendar adds functions to WP_Query filters and never removes t (5 posts)

  1. Eric Andrew Lewis
    Member
    Posted 1 year ago #

    If you're running a Tribe query, some functions are added to filters that are basic to the WP_Query class, which is making for some unexpected SQL in following custom queries which have nothing to do with events.

    Tracked it down to these specific filter adds:

    lib/tribe-event-query.class:31 add_filter( 'posts_join', array(__CLASS__, 'setupJoins' ), 10, 2 );
    lib/tribe-event-query.class:33 add_filter( 'posts_fields', array(__CLASS__, 'setupFields' ) );

    There should be a complementing method in this class, that hooks onto the end of the WP Query and removes these filters.

    http://wordpress.org/extend/plugins/the-events-calendar/

  2. roblagatta
    Modern Tribe Support
    Plugin Author

    Posted 1 year ago #

    Hi, Eric. Thanks for the report on this and apologies that we've taken some time to get you a response here. This is a solid bit of feedback and while it's outside my particular area of expertise, I've asked Paul - the lead dev behind this plugin - to take a look and see what's up here. If upon reviewing your note he sees action is needed, we'll definitely work it into one of our next monthly maintenance releases.

    Stay tuned and thanks again for the heads up, and your support so far.

  3. Daniel Dvorkin (MZAWeb)
    Member
    Plugin Contributor

    Posted 1 year ago #

    Hey Eric!

    Both lines are wrapped inside a big IF which should be true only when post_type == TribeEvents::POSTTYPE, so... could you please post (or PM me if you prefer) in which scenario you are getting this filters interfering with your queries so I can debug and test?

    Thanks!

  4. Eric Andrew Lewis
    Member
    Posted 1 year ago #

    Hey MZAWeb,

    here's the issue.

    We created a custom page template. We're running a couple queries one after the other, a la:

    [Custom Query 1]
    [Tribe Events]
    [Custom Query 2]

    The filters I mentioned earlier get the Tribe events specific functions added on to them. However at [Custom Query 2] these functions are still attached to the filter, so unnecessary joins are being added to [Custom Query 2], which should not be there.

    Let me know if that makes sense.

  5. Daniel Dvorkin (MZAWeb)
    Member
    Plugin Contributor

    Posted 1 year ago #

    Makes sense! Interesting that this wasn't reported yet. I see where we need to clean after the query now. I'll log this in our tickets for resolution.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.