Logic bug in tribe_get_events_title()

Home Forums Calendar Products Events Calendar PRO Logic bug in tribe_get_events_title()

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #926822
    Julia Miller
    Participant

    My apologies if this isn’t the right mechanism to report this; I didn’t see any info on bug tracking on your site. This bug is present in v3.8 of the plugin.

    Repro:
    – delete all pre-existing events
    – create a recurring event that starts 12/1/2014 and ends 6/1/2015
    – create an event that occurs on 12/31/2014
    – search for events on 12/30/2014

    -> tribe_get_events_title() says the date range is “June 1, 2015 to Dec 31”, which is nonsense. Since it looks like the requested date is actually a *start date*, I hacked loop.php:135 to fix this:

    			// tribe-bar-date is actually the requested start date of the range, so the title should reflect that
                            $first_event_date = tribe_event_format_date( strtotime($_REQUEST['tribe-bar-date']), false);

    So the bug no longer shows on our site below.

    #928841
    Brook
    Participant

    Howdy Rkaiser,

    Thanks for the super detailed bug report! This is a great venue for reporting bugs. Our bug tracker is internal so I can log issues for it when you report them here.

    I followed your steps to the letter, including trashing all of my existing events. But, my result was different. It showed “Dec 30 – June 1“, as it should. In light of that, is there anything you did not listed in those steps? Is it possible that a theme or plugin you’re running might be the culprit, or were you able to reproduct it on the Twenty Fourteen theme with only Tribe plugins enabled? – Not that this is required of you, but it is how I was testing when trying to reproduce.

    Let me know if you don’t mind. Thanks again!

    – Brook

    #928852
    Julia Miller
    Participant

    I don’t have time to repro this with the base theme and no plugins but I assure you those would not affect this. Looking at the original code you have for loop.php (at least in my version 3.8), it’s obvious what is wrong:

    function tribe_get_events_title( $depth = true ) {
    
    		global $wp_query;
    
    		$tribe_ecp = TribeEvents::instance();
    
    		$title = __( 'Upcoming Events', 'tribe-events-calendar' );
    
    		if ( isset( $_REQUEST['tribe-bar-date'] ) && $wp_query->have_posts() ) {
    
    // This is your problem: it displays the *end dates* of the first and last items in the set.  With recurrence
    // that's not necessarily want you'd want.  I did the simple fix of using the requested date for the first one, but
    // actually the second one should be changed as well to be the latest end date in the result set - unless
    // the original query is already sorting by ascending end date (which it might be, I don't recall).
    
    			$first_event_date = tribe_get_end_date( $wp_query->posts[0], false );
    			$last_event_date = tribe_get_end_date( $wp_query->posts[count( $wp_query->posts ) - 1], false );
    
    			$title = sprintf( __( 'Events for %1$s - %2$s', 'tribe-events-calendar'), $first_event_date, $last_event_date );
    ...

    I’ll bet that you cannot repro it right now with those dates I gave since the current date is later, so try

    Repro:
    – delete all pre-existing events
    – create a recurring event that starts 12/1/2014 and ends 6/1/2015
    – create an event that occurs on 1/15/2015
    – search for events on 1/5/2015 (today)

    #929062
    Brook
    Participant

    I am still unable to reproduce. We actually rewrote some of this logic in 3.9, and I see you posted that you are on 3.8. Is it possible that updating will fix it for you? Hopefully so… Actually in 3.9 we expressly use the $_REQUEST[‘tribe-bar-date’] not $wp_query->posts[0]. I bet that is the problem.

    – Brook

    #929072
    Julia Miller
    Participant

    Well that would fix it since that’s exactly the hack I did in 3.8.

    Thanks for the help, you can close this.

    #929357
    Brook
    Participant

    Thank you for your interest in making our plugin bug free! I do appreciate it. Let us know if you need help updating or anything. Cheers!

    – Brook

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Logic bug in tribe_get_events_title()’ is closed to new replies.