From e353c2841a127c82eb46277cb11449879c306a3f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 17 May 2019 22:27:55 +0000 Subject: [PATCH] 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 --- src/wp-includes/taxonomy.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index 12864b343a..9f84855257 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -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; /*