• Resolved daymobrew

    (@daymobrew)


    I run a nightly script that creates events.
    In 5.7.3 is works, creating the event with the appropriate row in the post and event tables.
    In 5.8.x it doesn’t work. It does not create the row in the event table.
    If I edit the event in the admin and simply Update it then everything is okay (Quick Edit is not sufficient).

    I have a standalone script that demonstrates the issue. I only specify the event name, start date, start time and description.

    https://gist.github.com/damiencarbery/3b20dfccf7530a9f6b81418aface792d

    At the end post_id is set but event_id is not.

    When I look at the post meta for the event, _event_id is null until I do the update.
    Even then $event_truly_exists is false and it has to call
    $wpdb->insert(EM_EVENTS_TABLE, $event_array)
    on line 964 of classes/em-event.php
    to get $this->event_id (via $wpdb->insert_id).

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter daymobrew

    (@daymobrew)

    I looked at the database before and after I clicked “Update” in the Edit Event page.

    Before:
    – No row created in ${prefix}_em_events table
    – _event_id is null in postmeta

    After:
    – Row is created in ${prefix}_em_events table
    – _event_id is set to index of this new row
    – _event_start_time and _event_end_time have the ‘seconds’ portion set to 0 (this is not a problem for me but just a bit strange).
    – _edit_lock and_edit_last postmeta is created.

    I’m not seeing anything in the changelog that would seem to relate to this. Which version of WordPress are you using?

    Thread Starter daymobrew

    (@daymobrew)

    Version 4.9.1.

    From changelog: Maybe these items:
    – changed and optimized postmeta saving process to reduce number of rows by up to 80% per event,
    – added cache optimization for event and location loading,

    The EM_Event::save() code has changed quite a bit between 5.7.3 and 5.8.

    Have you been able to try the code I posted?
    Put it into a file in the root folder and run that url from the browser.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    we will try the code and update you here however using your php logs; are you able to see any error or it’s just not working and no logs as well?

    Thread Starter daymobrew

    (@daymobrew)

    No logs, just not working.

    Thread Starter daymobrew

    (@daymobrew)

    I mean, no error messages in the logs.

    Thread Starter daymobrew

    (@daymobrew)

    I ran it again and it generated an error message:

    [06-Dec-2017 14:03:46 UTC] Query: INSERT INTO em_em_events (post_id, event_slug, event_owner, event_name, event_start_time, event_end_time, event_all_day, event_start_date, event_end_date, post_content, event_rsvp, event_rsvp_date, event_rsvp_time, event_rsvp_spaces, event_spaces, location_id, recurrence_id, event_status, event_private, blog_id, group_id, recurrence, recurrence_interval, recurrence_freq, recurrence_days, recurrence_byday, recurrence_byweekno, recurrence_rsvp_days, event_date_created) VALUES (17, ’em-test-02′, ‘1’, ‘EM Test – 02′, ’12:02:14′, ’12:02:14’, NULL, ‘2017-12-07’, ‘2017-12-07’, ‘<p>This is the description of EM Test event.</p><p>It is on Thursday 07 December 2017 pm31 12:02:14.</p>’, NULL, NULL, ’00:00:00′, NULL, NULL, ‘1’, NULL, ‘1’, ‘0’, NULL, NULL, ‘0’, NULL, NULL, ‘0’, NULL, NULL, NULL, ‘2017-12-06 14:03:23’)
    [06-Dec-2017 14:03:46 UTC] WordPress database error Column ‘event_rsvp’ cannot be null for query INSERT INTO em_em_events (post_id, event_slug, event_owner, event_name, event_start_time, event_end_time, event_all_day, event_start_date, event_end_date, post_content, event_rsvp, event_rsvp_date, event_rsvp_time, event_rsvp_spaces, event_spaces, location_id, recurrence_id, event_status, event_private, blog_id, group_id, recurrence, recurrence_interval, recurrence_freq, recurrence_days, recurrence_byday, recurrence_byweekno, recurrence_rsvp_days, event_date_created) VALUES (17, ’em-test-02′, ‘1’, ‘EM Test – 02′, ’12:02:14′, ’12:02:14’, NULL, ‘2017-12-07’, ‘2017-12-07’, ‘<p>This is the description of EM Test event.</p><p>It is on Thursday 07 December 2017 pm31 12:02:14.</p>’, NULL, NULL, ’00:00:00′, NULL, NULL, ‘1’, NULL, ‘1’, ‘0’, NULL, NULL, ‘0’, NULL, NULL, ‘0’, NULL, NULL, NULL, ‘2017-12-06 14:03:23’) made by EM_Event->save, EM_Event->save_meta
    [06-Dec-2017 14:03:46 UTC] PHP Notice: Undefined variable: result_tickets in C:\xampp\htdocs\wordpress\wp-content\plugins\events-manager\classes\em-bookings.php on line 315
    [06-Dec-2017 14:03:46 UTC] PHP Stack trace:
    [06-Dec-2017 14:03:46 UTC] PHP 1. {main}() C:\xampp\htdocs\wordpress\create-em-event.php:0
    [06-Dec-2017 14:03:46 UTC] PHP 2. EM_Event->save() C:\xampp\htdocs\wordpress\create-em-event.php:75
    [06-Dec-2017 14:03:46 UTC] PHP 3. EM_Event->save_meta() C:\xampp\htdocs\wordpress\wp-content\plugins\events-manager\classes\em-event.php:852
    [06-Dec-2017 14:03:46 UTC] PHP 4. EM_Bookings->delete() C:\xampp\htdocs\wordpress\wp-content\plugins\events-manager\classes\em-event.php:996

    This block of code in classes/em-event.php has changed quite a bit since 5.7.3 (“Update Post Meta” comment at top)
    https://plugins.trac.wordpress.org/browser/events-manager/tags/5.8.1.1/classes/em-event.php#L891
    It has gone from 16 lines of code to 38 lines and ‘event_rsvp’ is one of the fields in the new code.

    Thread Starter daymobrew

    (@daymobrew)

    I think I have found a workaround.

    I am setting event_name, post_content, location_id, event_start_date, event_end_date, event_start_time, event_end_time, start and end fields of EM_Event.

    When I add:
    $EM_Event->event_rsvp = false;
    then it works.

    Maybe this field should be initialised by Events Manager or maybe the new code mentioned above is causing a problem, preventing it from be initialised.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘$EM_Event->save() not working in 5.8.x – okay in 5.7.3’ is closed to new replies.