• Hello,

    I sometime get an error while trying to publish a new event :
    Something went wrong saving your event to the index table

    I looked at the PHP logs, but none are issued (even in DEBUG mode, where only fpm_event_loop() lines are emitted)

    How can I make the event manager logging more ? Maybe if I can see the request beeing issued I could figure out the problem ?

    System : Debian12 / PHP-FPM 8.2 / EM 6.4.6.4 / WP 6.4.2

    Thanks,

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter Bastien Durel

    (@bastiendurel)

    Thanks for your answer, but it doesn’t help me : as I said, I cannot see any error in logs.

    I did not explicitly said it, but I have some events (~200) in database, so I think it cannot be a missing column, or it would have prevented any insertion. (unless they are inserted in different way depending of some context)

    As suggested in the thread that I referenced, you can refer to the file events-manager/em-install.php function em_create_events_table() to verify and confirm your events table (wp_em_event) has the required fields. It’s possible that the events already in the database and the new version of Events Manager has added additional fields. I see a new field was added in version 6.4.3 called event_active_status.

       event_active_status tinyint(2) NULL DEFAULT 1,
    Thread Starter Bastien Durel

    (@bastiendurel)

    It has all the (39) fields

    I see the following code in the save function in events-manager/classes/em-event.php:

                   if ( !$wpdb->insert(EM_EVENTS_TABLE, $event_array) ){
                        $this->add_error( sprintf(__('Something went wrong saving your %s to the index table. Please inform a site administrator about this.','events-manager'),__('event','events-manager')));
    

    You could change this to the following:

                   if ( !$wpdb->insert(EM_EVENTS_TABLE, $event_array) ){
                        $this->add_error( sprintf(__('Something went wrong saving your %s to the index table. Please inform a site administrator about this.','events-manager'),__('event','events-manager')) . "event_array:" . print_r($event_array, true);
    

    This might give you a clue about the source of the problem.

    • This reply was modified 8 months, 3 weeks ago by joneiseman.
    Thread Starter Bastien Durel

    (@bastiendurel)

    Hello.

    This print_r is not very useful, as it only displays the data which has to be inserted.

    But I wrote $wpdb->print_error(); just after the add_error(), and get this message in log file :

    [29-Jan-2024 19:09:35 UTC] WordPress database error for query SHOW FULL COLUMNS FROM wp_em_events made by edit_post, wp_update_post, wp_insert_post, do_action('save_post'), WP_Hook->do_action, WP_Hook->apply_filters, EM_Event_Post_Admin::save_post, EM_Event->save_meta

    That’s very strange, because I can run the said query from mysql CLI :

    root@agendap:/var/www/html/wordpress/wp-content/plugins/events-manager# mysql --defaults-file=/root/agendap.cnf -h 10.126.0.42 agenda_p
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Welcome to the MariaDB monitor. Commands end with ; or \g.
    Your MariaDB connection id is 1315
    Server version: 10.11.4-MariaDB-1~deb12u1-log Debian 12
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [agenda_p]> SHOW FULL COLUMNS FROM wp_em_events;
    +----------------------+---------------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
    | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
    +----------------------+---------------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
    | event_id | bigint(20) unsigned | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | |
    | post_id | bigint(20) unsigned | NULL | NO | MUL | NULL | | select,insert,update,references | |
    | event_parent | bigint(20) unsigned | NULL | YES | | NULL | | select,insert,update,references | |
    | event_slug | varchar(200) | utf8mb3_general_ci | YES | | NULL | | select,insert,update,references | |
    | event_owner | bigint(20) unsigned | NULL | YES | | NULL | | select,insert,update,references | |
    | event_status | tinyint(1) | NULL | YES | MUL | NULL | | select,insert,update,references | |
    | event_active_status | tinyint(2) | NULL | YES | MUL | 1 | | select,insert,update,references | |
    | event_name | text | utf8mb3_general_ci | YES | | NULL | | select,insert,update,references | |
    | event_start_date | date | NULL | YES | MUL | NULL | | select,insert,update,references | |
    | event_end_date | date | NULL | YES | MUL | NULL | | select,insert,update,references | |
    | event_start_time | time | NULL | YES | | NULL | | select,insert,update,references | |
    | event_end_time | time | NULL | YES | | NULL | | select,insert,update,references | |
    | event_all_day | tinyint(1) unsigned | NULL | YES | | NULL | | select,insert,update,references | |
    | event_start | datetime | NULL | YES | MUL | NULL | | select,insert,update,references | |
    | event_end | datetime | NULL | YES | MUL | NULL | | select,insert,update,references | |
    | event_timezone | tinytext | utf8mb3_general_ci | YES | | NULL | | select,insert,update,references | |
    | post_content | longtext | utf8mb3_general_ci | YES | | NULL | | select,insert,update,references | |
    | event_rsvp | tinyint(1) unsigned | NULL | NO | | 0 | | select,insert,update,references | |
    | event_rsvp_date | date | NULL | YES | | NULL | | select,insert,update,references | |
    | event_rsvp_time | time | NULL | YES | | NULL | | select,insert,update,references | |
    | event_rsvp_spaces | int(5) | NULL | YES | | NULL | | select,insert,update,references | |
    | event_spaces | int(5) | NULL | YES | | 0 | | select,insert,update,references | |
    | event_private | tinyint(1) unsigned | NULL | NO | | 0 | | select,insert,update,references | |
    | location_id | bigint(20) unsigned | NULL | YES | MUL | NULL | | select,insert,update,references | |
    | event_location_type | varchar(15) | utf8mb3_general_ci | YES | | NULL | | select,insert,update,references | |
    | recurrence_id | bigint(20) unsigned | NULL | YES | | NULL | | select,insert,update,references | |
    | event_date_created | datetime | NULL | YES | | NULL | | select,insert,update,references | |
    | event_date_modified | datetime | NULL | YES | | NULL | | select,insert,update,references | |
    | recurrence | tinyint(1) unsigned | NULL | NO | | 0 | | select,insert,update,references | |
    | recurrence_interval | int(4) | NULL | YES | | NULL | | select,insert,update,references | |
    | recurrence_freq | tinytext | utf8mb3_general_ci | YES | | NULL | | select,insert,update,references | |
    | recurrence_byday | tinytext | utf8mb3_general_ci | YES | | NULL | | select,insert,update,references | |
    | recurrence_byweekno | int(4) | NULL | YES | | NULL | | select,insert,update,references | |
    | recurrence_days | int(4) | NULL | YES | | NULL | | select,insert,update,references | |
    | recurrence_rsvp_days | int(3) | NULL | YES | | NULL | | select,insert,update,references | |
    | blog_id | bigint(20) unsigned | NULL | YES | MUL | NULL | | select,insert,update,references | |
    | group_id | bigint(20) unsigned | NULL | YES | MUL | NULL | | select,insert,update,references | |
    | event_language | varchar(14) | utf8mb3_general_ci | YES | | NULL | | select,insert,update,references | |
    | event_translation | tinyint(1) unsigned | NULL | NO | | 0 | | select,insert,update,references | |
    +----------------------+---------------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
    39 rows in set (0.001 sec)
    
    MariaDB [agenda_p]> ^DBye
    • This reply was modified 8 months, 3 weeks ago by Bastien Durel.

    The error occurred after the following call: $wpdb->insert(EM_EVENTS_TABLE, $event_array)

    To get an idea why this failed it would be helpful to know the contents of the $event_array. This call would not results in a “FULL COLUMNS FROM wp_em_events” mysql query. One reason this insert may fail would be if the $event_array was trying to insert a value into a field that didn’t exist in the table.

    Thread Starter Bastien Durel

    (@bastiendurel)

    Here is the code :

                if ( !$wpdb->insert(EM_EVENTS_TABLE, $event_array) ){
                    $wpdb->print_error();
                    error_log(print_r($event_array, true));
                    $this->add_error( sprintf(__('Something went wrong saving your %s to the index table. Please inform a site administrator about this.','events-manager'),__('event','events-manager')));
                }

    Here is the event array :

    [post_id] => 2810
    [event_parent] =>
    [event_slug] => chants[…]
    [event_owner] => 2
    [event_name] => Chants[…]
    [event_timezone] => Europe/Paris
    [event_start_time] => 10:00:00
    [event_end_time] => 16:30:00
    [event_start] => 2024-02-04 09:00:00
    [event_end] => 2024-02-04 15:30:00
    [event_all_day] => 0
    [event_start_date] => 2024-02-04
    [event_end_date] => 2024-02-04
    [post_content] => Départ[…]
    [event_rsvp] => 0
    [event_rsvp_date] =>
    [event_rsvp_time] =>
    [event_rsvp_spaces] =>
    [event_spaces] =>
    [location_id] => 268
    [event_location_type] =>
    [recurrence_id] =>
    [event_status] => 1
    [event_active_status] => 1
    [event_private] => 0
    [blog_id] => 0
    [group_id] => 0
    [event_language] => fr_FR
    [event_translation] => 0
    [recurrence] => 0
    [recurrence_interval] =>
    [recurrence_freq] =>
    [recurrence_days] =>
    [recurrence_byday] =>
    [recurrence_byweekno] =>
    [recurrence_rsvp_days] =>
    [event_date_created] => 2024-01-29 19:41:50

    So no extra column. No not-null-without-default column either.

    Edit: I tcpdump’ed communications with the SQL server, and this request (SHOW FULL COLUMNS FROM wp_em_events) is done, without error
    Edit 2: I did not found any INSERT statement in the dump

    Did you edit the output from the print_r? The value of event_slug should be “chants” (not “chants […]”).

    If you want to see the queries you can use the “query” filter. For example:

    add_filter('query', function( $query ) {
        error_log("query:" . $query);
    } );
    Thread Starter Bastien Durel

    (@bastiendurel)

    Hello.

    Looks like removing an emoji (??) from the main post made it work

    Thread Starter Bastien Durel

    (@bastiendurel)

    Yes, I edited the values to not put all the text on the forum. I did not though the actual data could change the behaviour

    Thread Starter Bastien Durel

    (@bastiendurel)

    But it fails. When I put the tree in text, I get the error, if I remove it, the event can be created :/

    post_content is created as longtext with utf8mb3_general_ci

    The version from 7 years ago introduced em_check_utf8mb4_tables, which does not seems to have changed ever since. Maybe it should be updated to handle utf8mb3 -> utf8mb4 ? I’m not sure if utf8mb3 can store emojis

    the maybe_convert_table_to_utf8mb4 function emits the “SHOW TABLE STATUS LIKE ‘$table'” query I’ve seen

    I’ve checked the tables, and all wp_em_* tables are created with utf8mb3_general_ci collation, but other wp_* tables are created with utf8mb4_unicode_520_ci

    Maybe the plugin author will read this and fix the problem but I’m not holding my breath.

    Thread Starter Bastien Durel

    (@bastiendurel)

    I’ve fixed the problem on my side by running ALTER TABLE wp_em_* CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci on every table, but it would be better if they can be create correctly (and migrated otherwise)

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Something went wrong saving your event to the index table’ is closed to new replies.