Make WordPress Core

Changeset 21766


Ignore:
Timestamp:
09/05/2012 05:57:53 PM (12 years ago)
Author:
ryan
Message:

Return WP_Error if the db insert in wp_set_object_terms() fails. Props jndetlefsen. fixes #21800

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r21758 r21766  
    22262226                $values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $tt_id, ++$term_order);
    22272227        if ( $values )
    2228             $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)");
     2228            if ( false === $wpdb->query( "INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join( ',', $values ) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)" ) )
     2229                return new WP_Error( 'db_insert_error', __( 'Could not insert term relationship into the database' ), $wpdb->last_error );
    22292230    }
    22302231
Note: See TracChangeset for help on using the changeset viewer.