Changeset 15425
- Timestamp:
- 07/14/2010 02:12:23 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/taxonomy.php
r15355 r15425 1631 1631 $existing_term = $wpdb->get_row( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE term_id = %d", $term_id), ARRAY_A ); 1632 1632 // We've got an existing term in the same taxonomy, which matches the name of the new term: 1633 if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name && term_exists( (int) $term_id, $taxonomy ) ) {1633 if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name && $exists = term_exists( (int) $term_id, $taxonomy ) ) { 1634 1634 // Hierarchical, and it matches an existing term, Do not allow same "name" in the same level. 1635 1635 $siblings = get_terms($taxonomy, array('fields' => 'names', 'get' => 'all', 'parent' => (int)$parent) ); 1636 1636 if ( in_array($name, $siblings) ) { 1637 return new WP_Error('term_exists', __('A term with the name provided already exists with this parent.') );1637 return new WP_Error('term_exists', __('A term with the name provided already exists with this parent.'), $exists['term_id']); 1638 1638 } else { 1639 1639 $slug = wp_unique_term_slug($slug, (object) $args); … … 1648 1648 return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); 1649 1649 $term_id = (int) $wpdb->insert_id; 1650 } elseif ( term_exists( (int) $term_id, $taxonomy ) ) {1650 } elseif ( $exists = term_exists( (int) $term_id, $taxonomy ) ) { 1651 1651 // Same name, same slug. 1652 return new WP_Error('term_exists', __('A term with the name provided already exists.') );1652 return new WP_Error('term_exists', __('A term with the name provided already exists.'), $exists['term_id']); 1653 1653 } 1654 1654 } else { -
trunk/xmlrpc.php
r14418 r15425 934 934 ); 935 935 936 $cat_id = wp_insert_category($new_category); 937 if ( !$cat_id ) 936 $cat_id = wp_insert_category($new_category, true); 937 if ( is_wp_error( $cat_id ) ) { 938 if ( 'term_exists' == $cat_id->get_error_code() ) 939 return (int) $cat_id->get_error_data(); 940 else 941 return(new IXR_Error(500, __("Sorry, the new category failed."))); 942 } elseif ( ! $cat_id ) { 938 943 return(new IXR_Error(500, __("Sorry, the new category failed."))); 944 } 939 945 940 946 return($cat_id);
Note: See TracChangeset
for help on using the changeset viewer.