• Resolved josephparsley

    (@josephparsley)


    It seems like previously tribe_get_events() would return EventStartDate and EventEndDate by default, and it’s no longer doing this. This breaks old code that assumed those values would be there.

    You can still get these values after the fact by calling get_post_meta() for these values and adding it to the result, but is this an intentional change, so this will need to be done going forward, or is it a bug?

Viewing 9 replies - 1 through 9 (of 9 total)
  • We’ve also seen this break several sites. The change log for update to v4.9.0, or older versions, did not mention this change. Sometimes we’ve also seen that a new property, event_date, has appeared and which maps to the start date.

    In some cases we’ve fixed by using tribe_get_end_date(), for example, but if this was an intentional change some heads up in the changelog that this update included a breaking change would’ve been great.

    Thread Starter josephparsley

    (@josephparsley)

    This remains an issue in 4.9.0.2. I’m still not sure if this was an intentional change but if it was it’d be helpful to at least have that acknowledged.

    I also have this issue on at least one site. Digging into the source, it appears it’s supposed to be returning it but isn’t so it must be a bug. Any update here Modern Tribe??

    No word yet from Modern Tribe on this so I wrote a patch for now. Just add this snippet to your theme functions file and those two meta values will be returned in the event object as they were before:

    add_filter( 'tribe_get_events', 'mdw_add_back_EventEndDate', 5, 1 );
    
    function mdw_add_back_EventEndDate($events){
    	$updated_events = array();
    	
    	foreach($events as $event):
    		$event->EventStartDate = tribe_get_start_date( $event, false, 'Y-m-j g:i a');
    		$event->EventEndDate = tribe_get_end_date( $event, false, 'Y-m-j g:i a');
    		$updated_events[]=$event;
    	endforeach;
    		
    	return $updated_events;
    }

    We had the same issue. Your patch fixed it. I’m going to submit a trouble ticket through our account as well. Thanks for posting this!

    Was there an update to this? Was it a bug?

    We recently found this same error on a client website. The snippet posted by marshalloram works like a charm.

    Client is running 4.9.11

    I found no documentation or posts from other developers so I feel lucky to have solved it.

    @marshalloram

    I’m seeing errors related to EventStartDate in some query, so tried to use your patch. That seems to result in more errors… I think things may have changed over the last 11 months.

    Am I missing something obvious here?

    PHP Warning:  Attempt to assign property 'EventStartDate' of non-object in...
    PHP Warning:  Attempt to assign property 'EventEndDate' of non-object in...
    
    PHP Fatal error:  Uncaught Tribe__Repository__Usage_Error: The Tribe__Events__Pro__Repositories__Event class does not define a ID property; add it by decorating or extending this class. in /home/hirensha/public_html/sites/staging.r8drive.co.uk/wp-content/plugins/the-events-calendar/common/src/Tribe/Repository/Usage_Error.php:62
    Stack trace:
    #0 /wp-content/plugins/the-events-calendar/common/src/Tribe/Repository.php(462): Tribe__Repository__Usage_Error::because_property_is_not_defined('ID', Object(Tribe__Events__Pro__Repositories__Event))
    #1 /wp-content/plugins/the-events-calendar/common/src/functions/template-tags/date.php(296): Tribe__Repository->__get('ID')
    #2 /wp-content/themes/oceanwp-child/functions.php(272): tribe_get_start_date(Object(Tribe__Events__Pro__Repositories__Event), false, 'Y-m-j g:i a')
    #3 /wp-incl in /wp-content/plugins/the-events-calendar/common/src/Tribe/Repository/Usage_Error.php on line 62

    @marshalloram

    Ignore the above post… deactivating and then reactivating the plugins seems to have sorted everything, without actually needing that function.

    Should have tried that first lol!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘tribe_get_events stopped returning EventStartDate and EventEndDate by default’ is closed to new replies.