WordPress.org

Make WordPress Core

Ticket #47313: wp_insert_term_catch_taxonomy_insert_error.diff

File wp_insert_term_catch_taxonomy_insert_error.diff, 740 bytes (added by mbabker, 16 months ago)
  • src/wp-includes/taxonomy.php

    diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
    index 12864b343a..9f84855257 100644
    function wp_insert_term( $term, $taxonomy, $args = array() ) { 
    22762276                        'term_taxonomy_id' => $tt_id,
    22772277                );
    22782278        }
    2279         $wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ) + array( 'count' => 0 ) );
     2279
     2280        if ( false === $wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ) + array( 'count' => 0 ) ) ) {
     2281                return new WP_Error( 'db_insert_error', __( 'Could not insert term taxonomy into the database.' ), $wpdb->last_error );
     2282        }
     2283
    22802284        $tt_id = (int) $wpdb->insert_id;
    22812285
    22822286        /*