• I’m seeing many messages in error_log with “Failed to insert log entry:”, but no error message afterwards.

    I’ve tracked down the string to lines 135-136 of core/lib/log.php:

    error_log( "Failed to insert log entry: {$wpdb->last_error}" );
    return new WP_Error( 'itsec-log-failed-db-insert', sprintf( esc_html__( 'Failed to insert log entry: %s', 'better-wp-security' ), $wpdb->last_error ) );

    Now I know there’s a problem, but I don’t know what it is…

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • According to Codex wpdb class doc:

    If the length of a string element in the $data array parameter is longer that the defined length in the MySql database table, the insert will fail, this function will return false, but $wpdb->last_error will not be set to a descriptive message. You must ensure the data you wish to insert will fit in the database – do not assume the MySql will truncate the data.

    Note the above quote is taken from the $wpdb->replace method. But it also applies for the $wpdb->insert method.

    Just a quick update:

    Trac ticket #32167 seems to be relevant for this issue.

    It seems like there have been some changes to the core wpdb class in WordPress 4.2.0 which can lead to situations like this one.
    However if iThemes ensures the data to be inserted fits the database this would not be an issue.

    Question is: Does WordPress core wpdb class need patching or should iThemes perform sanity checks before inserting data ?

    Hmm, it seems WordPress core wpdb class needs patching. Trac ticket #32315 covers the whole issue and even includes a preliminary patch. Forget about trac ticket #32167 I mentioned earlier ??

    This certainly makes an interesting read.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘“Failed to insert log entry:” with no message in error_log’ is closed to new replies.