Taxonomy: In wp_insert_term(), handle an error if writing to the term_taxonomy table fails.

This complements the check for successful writing to the `terms` table, added in [7430].

Props mbabker.
Fixes #47313.

git-svn-id: https://develop.svn.wordpress.org/trunk@45362 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2019-05-17 22:27:55 +00:00
parent 0205cf09f0
commit e353c2841a

View File

@ -2276,7 +2276,11 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
'term_taxonomy_id' => $tt_id,
);
}
$wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ) + array( 'count' => 0 ) );
if ( false === $wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ) + array( 'count' => 0 ) ) ) {
return new WP_Error( 'db_insert_error', __( 'Could not insert term taxonomy into the database.' ), $wpdb->last_error );
}
$tt_id = (int) $wpdb->insert_id;
/*