View Past Events gorked

Home Forums Calendar Products Community Events View Past Events gorked

Viewing 9 posts - 16 through 24 (of 24 total)
  • Author
    Posts
  • #1058811
    Geoff B.
    Member

    Good afternoon Mad Dog,

    Thanks for doing the tests and I believe it does demonstrate that there is something weird going on for sure. I appreciate you patience on this as this is a fairly complex one.

    At this point to try to solve things will require a staging/test environment on your end (perhaps a local install?). Can you tell me if you have one ?

    Here are the tests that should be conducted:

    • Trying out a fresh install with the exact same plugins, WordPress theme and Theme customization. Once that’s done, we should go through the same past events tests. The goal being to isolate for sure that it is the DB that is in question.
    • Making a local exact copy of the site and reinstalling the most recent plugins one by one from a fresh source. This will establish if there was some problem during the plugin update process.
    • Making a local exact copy and trying to revert the plugins to the previous version. Again this will help isolating the cause of the issue.
    • Making a local exact copy and trying to clean up the database using the following tool

    Depending on the findings of these tests we should be one step closer to success!

    So hang in there and let me know if you have any questions about the tests ?

    Cheers,

    Geoff B.

     

    #1058894
    Mad Dog
    Participant

    Oh boy…what fun!

    #1059459
    Geoff B.
    Member

    Good afternoon,

    I know how you feel. You”re right, it probably does not qualify as fun.

    The good news however is that this should end the troubleshooting for good.

    So once again hang in there and let me know if you have questions about the tests.

    Looking forward to hearing about your results.

    Have a good one,

    Geoff B.

    #1059473
    Mad Dog
    Participant

    I’m not sure if it’s important to you that I do these in order. I’m not even sure how to do #1 without it taking forever. The basics are fine until it gets to the plugins. Without cloning the db it means going through every one to make sure the settings are identical. That will take hours in itself.

    I did the simplest test first: Created a local WP installation, cloned the existing site, then used your cleaner. No joy. I then did a MySQL search for Drafts and deleted them. Repaired and optimized the db. The draft no longer shows up in the admin. But it still won’t display past events. So I disabled all plugins except TEC, Pro and Community Events. It still won’t display Past Events.

    I MIGHT BE ONTO SOMETHING….

    For yucks, I renamed the functions.php and used the original one. It works fine. So it looks like something in the functions which is odd….it’s either a most-recent function I added or an earlier one that with the updates no longer works right. I don’t have time now but will go through it and disable my functions one by one and find the offender. I might need advice on fixing the offender.

    Getting somewhere…I hope!

    THANKS
    MD

    #1059476
    Mad Dog
    Participant

    I found the offender easily but need to know what changed with the recent version updates that made it stop working right and help with making it work again.

    I was trying to get it to only display Events (which are Courses for this client) that have a START DATE of today or in the future. End Date isn’t important for this. Once it’s started, it shouldn’t show up. I had a support question about it and we got it working (https://theeventscalendar.com/support/forums/topic/only-display-events-by-upcoming-start-date/).

    Somehow after the latest updates it’s apparently affecting the whole installation, not just List and Photo views, so it won’t show any events with a start date < today. (I’m pretty sure it was one of the maintenance updates, since it worked after 4.0 but stopped after.)

    I don’t know what changed but can you help me fix the function so it only affects List and Photo views and not admin or any other page? Here’s the code:

    // Only Display Events with Starting Date from today on //
    function start_date_strict($query) {
        $post_type = $query->query_vars['post_type']; 
     
        if ($post_type == 'tribe_events') {
     
            $filterDate = current_time('Y-m-d H:i:s');
            if (!empty( $_REQUEST['tribe-bar-date'] ) ) {
                $filterDate = $_REQUEST['tribe-bar-date'];
            }
     
            $query->query_vars['meta_query'][] = 
                     array(         // restrict posts based on meta values
                        'key'     => '_EventStartDate',  // which meta to query
                        'value'   => $filterDate,  // value for comparison
                        'compare' => '>=',          // method of comparison
                        'type'    => 'DATETIME');
        }
    }
    add_filter( 'tribe_events_pre_get_posts', 'start_date_strict', 100, 1 );

    THANKS….so close now!

    • This reply was modified 8 years, 3 months ago by Mad Dog.
    #1060054
    Geoff B.
    Member

    Hey Mad Dog,

    Good work on finding the culprit!

    It sounds like your function is affecting all of the views because there’s not view ‘conditionals’ in there.

    As you know, our support for such customizations is limited, but we like to point our customers in the right direction.

    You will need to run conditions on the $query->get(‘eventDisplay’), making sure it matches the value of the photo or list views.

    I guess it should be something like (untested)

    https://gist.github.com/GeoffEW/09db9e7faca054f98480

    As an alternative, you can use the following functions:

    https://theeventscalendar.com/function/tribe_is_photo/

    https://theeventscalendar.com/function/tribe_is_list_view/

    Almost there, let me know if that helps

    Geoff B.

     

     

    #1060236
    Mad Dog
    Participant

    *Ding!*Ding!*Ding!*Ding!

    I do believe I’ve got it….

    I changed one line to include the two TEC functions like this:

    if ($post_type == 'tribe_events' && (tribe_is_list_view() || tribe_is_photo() ) ) {

    and now it all seems to work as it should. List and Photos only show events which haven’t begun yet, Past Events show up in Admin and in the Community Events edit page (when Past Events is clicked)….seems good! I’m going to have the client check behind me just to be certain, of course.

    I’m still curious why it worked before the maintenance updates without the conditionals. But regardless, it seems good now.

    THANKS A MILLION FOR STICKING WITH ME ON THIS!

    If anyone is interested, here’s the final Function to only show events that haven’t begun (ignoring the end dates) for List and Photo views:

    // Only Display Events with Starting Date from today on //
    function start_date_strict($query) {
        $post_type = $query->query_vars['post_type']; 
     
     //   if ($post_type == 'tribe_events') {  **ORIGINAL** 
          if ($post_type == 'tribe_events' && (tribe_is_list_view() || tribe_is_photo() ) ) {
     
            $filterDate = current_time('Y-m-d H:i:s');
            if (!empty( $_REQUEST['tribe-bar-date'] ) ) {
                $filterDate = $_REQUEST['tribe-bar-date'];
            }
     
            $query->query_vars['meta_query'][] = 
                     array(         // restrict posts based on meta values
                        'key'     => '_EventStartDate',  // which meta to query
                        'value'   => $filterDate,  // value for comparison
                        'compare' => '>=',          // method of comparison
                        'type'    => 'DATETIME');
        }
    }
    add_filter( 'tribe_events_pre_get_posts', 'start_date_strict', 100, 1 );
    

    Thanks again! I’ll let you know if the client finds anything but after all this work we got it licked. Oh yeah…let me know if you see anything in there that isn’t good code or needs fixing.

    Mad Dog

    #1060677
    Geoff B.
    Member

    Good afternoon Mad Dog,

    Way to go! Kudos to you!

    I’m glad we were helpful to you on this journey, that’s what we are here for.
    I can’t say for sure why everything worked prior to the update, but at any rate, your current code is much more robust and proper.

    Thanks for sharing it with us. I don’t see anything suspicious about it, good job.

    Have a great weekend and let us know if you find anything else on this.

    Geoff B.

     

    #1078186
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 9 posts - 16 through 24 (of 24 total)
  • The topic ‘View Past Events gorked’ is closed to new replies.