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
This commit is contained in:
Sergey Biryukov 2019-05-17 22:28:51 +00:00
parent f72cb6dc83
commit f29eba6662
2 changed files with 6 additions and 2 deletions

View File

@ -2276,7 +2276,11 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
'term_taxonomy_id' => $tt_id, '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; $tt_id = (int) $wpdb->insert_id;
/* /*

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.