From 4784e3bd975e40bc1c04accd59e8db8e50e1d97d Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 20 Mar 2008 22:33:34 +0000 Subject: [PATCH] Return error if term DB insert fails git-svn-id: http://svn.automattic.com/wordpress/trunk@7430 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 7f2205045..41d1035d9 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -1152,13 +1152,15 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) { } if ( ! $term_id = is_term($slug) ) { - $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ); + if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) + return new WP_Error('db_insert_error', __('Could not insert term into the database')); $term_id = (int) $wpdb->insert_id; } else if ( is_taxonomy_hierarchical($taxonomy) && !empty($parent) ) { // If the taxonomy supports hierarchy and the term has a parent, make the slug unique // by incorporating parent slugs. $slug = wp_unique_term_slug($slug, (object) $args); - $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ); + if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) + return new WP_Error('db_insert_error', __('Could not insert term into the database')); $term_id = (int) $wpdb->insert_id; }