From f29eba66628cd7f54ff2abd8c38b4dd46625d24c Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 17 May 2019 22:28:51 +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. Built from https://develop.svn.wordpress.org/trunk@45362 git-svn-id: http://core.svn.wordpress.org/trunk@45173 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 6 +++++- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 12864b343a..9f84855257 100644 --- a/wp-includes/taxonomy.php +++ b/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; /* diff --git a/wp-includes/version.php b/wp-includes/version.php index b6bc689089..fbf79765e9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45357'; +$wp_version = '5.3-alpha-45362'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.