Support » Plugin: All-in-One Event Calendar » New Event Post with old ai1ec verison and new wordpress

  • Resolved CatchThePigeon


    Hi – I am still using Version 1.10.11 of the event calendar so there may be little you are willing to help me with, however all my custom behaviour for the calendar theme is written in PHP and the new versions rely on twig which means I can’t blend functionality.

    When updating WordPress from our old version 4.1.1 to 4.6.1 something changes in the way new posts are made which breaks the query ai1ec gets the new post with.

    [16-Nov-2016 16:28:20 UTC] PHP Fatal error:  Uncaught Ai1ec_Event_Not_Found: Post with ID '50220' could not be retrieved from the database. in xxxxxxxx/public_html/wp-content/plugins/all-in-one-event-calendar/app/model/class-ai1ec-event.php:423
    Stack trace:
    #0 xxxxxxxx/public_html/wp-content/plugins/all-in-one-event-calendar/app/helper/class-ai1ec-events-helper.php(70): Ai1ec_Event->__construct(50220, false)
    #1 xxxxxxxx/public_html/wp-content/themes/xxx/functions.php(545): Ai1ec_Events_Helper::get_event(50220)
    #2 xxxxxxxx/public_html/wp-includes/plugin.php(235): my_comments_open(false, Object(WP_Post))
    #3 xxxxxxxx/public_html/wp-includes/comment-template.php(1204): apply_filters('comments_open', false, Object(WP_Post))
    #4 xxxxxxxx/public_html/wp-admin/edit-form-advanced.php(289): comments_open(Object(WP_Post))
    #5 xxxxxxxx/public_html/wp-admin/post-new.php(85): include('xxxxxxxx...')
    #6 {main}
      thrown in xxxxxxxx/public_html/wp-content/plugins/all-in-one-event-calendar/app/model/class-ai1ec-event.php on line 423

    After playing around with it it seem to be that this bit of code is the culprit:

    if ( ! $post || $post->post_status == 'auto-draft' )
        throw new Ai1ec_Event_Not_Found( "Post with ID '$data' could not be retrieved from the database." );
    $left_join  = "";
    $select_sql = "e.post_id, e.recurrence_rules, e.exception_rules, " .
        "e.allday, e.instant_event, e.recurrence_dates, e.exception_dates, " .
        "e.venue,, e.address,, e.province, e.postal_code, " .
        "e.show_map, e.contact_name, e.contact_phone, e.contact_email, " .
        "e.contact_url, e.cost, e.ticket_url, e.ical_feed_url, " .
        "e.ical_source_url, e.ical_organizer, e.ical_contact, e.ical_uid, " .
        "e.longitude, e.latitude, e.show_coordinates, e.facebook_eid, " .
        "e.facebook_status, e.facebook_user, " .
        "GROUP_CONCAT( ttc.term_id ) AS categories, " .
        "GROUP_CONCAT( ttt.term_id ) AS tags ";
    if( $instance != false && is_numeric( $instance ) ) {
        $select_sql .= ", IF( aei.start IS NOT NULL, aei.start, e.start ) as start," .
                       "  IF( aei.start IS NOT NULL, aei.end,   e.end )   as end ";
        $instance = (int) $instance;
        $this->instance_id = $instance;
        $left_join = 	"LEFT JOIN {$wpdb->prefix}ai1ec_event_instances aei ON = $instance AND e.post_id = aei.post_id ";
    } else {
        $select_sql .= ", e.start as start, e.end as end, e.allday ";
    // =============================
    // = Fetch event from database =
    // =============================
    $query = $wpdb->prepare(
        "SELECT {$select_sql}" .
        "FROM {$wpdb->prefix}ai1ec_events e " .
            "LEFT JOIN $wpdb->term_relationships tr ON e.post_id = tr.object_id " .
            "LEFT JOIN $wpdb->term_taxonomy ttc ON tr.term_taxonomy_id = ttc.term_taxonomy_id AND ttc.taxonomy = 'events_categories' " .
            "LEFT JOIN $wpdb->term_taxonomy ttt ON tr.term_taxonomy_id = ttt.term_taxonomy_id AND ttt.taxonomy = 'events_tags' " .
            "{$left_join}" .
        "WHERE e.post_id = %d " .
        "GROUP BY e.post_id",
        $data );
    $event = $wpdb->get_row( $query );
    if ( $event === null || $event->post_id === null )
        throw new Ai1ec_Event_Not_Found( "Event with ID '$data' could not be retrieved from the database." );

    As the post is returned as an ‘auto-draft’ it triggers the first error. When removing the ‘auto-draft’ condition the error is triggered lower down as nothing is returned by the SQL query.

    I imagine a hook name has been changed somewhere in the new WP and ai1ec no longer does what it’s supposed to before or during new post creation.

    My question would be what’s changed and what actions does ai1ec try to carry out before the ‘auto-draft’ is created. Then I can look at fixing it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Benjamin



    This is several years old version so a lot has changed since then, unfortunately we can not help you with that since we no longer support this version. The main purpose of this forum is for us to catch and address product bugs, but hopefully other users can help you. We’ll keep this topic open for a few days for other user to chime in if possible. Thanks for your understanding.


    Hi @catchthepigeon,

    Apologies for the delay in responding to your inquiry. We’ve updated the calendar and have issued several bug fixes with the newest releases for our WordPress Core Plugin, as well as our hosted calendar versions.

    If you are still experiencing difficulty or for faster assistance, please login to your Timely account and click on the “Get Help” link. You may also reply to this ticket, or open a new ticket.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘New Event Post with old ai1ec verison and new wordpress’ is closed to new replies.