WordPress.org

Make WordPress Core

Changeset 45362


Ignore:
Timestamp:
05/17/2019 10:27:55 PM (14 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

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

    r44894 r45362  
    22772277        );
    22782278    }
    2279     $wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ) + array( 'count' => 0 ) );
     2279
     2280    if ( false === $wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ) + array( 'count' => 0 ) ) ) {
     2281        return new WP_Error( 'db_insert_error', __( 'Could not insert term taxonomy into the database.' ), $wpdb->last_error );
     2282    }
     2283
    22802284    $tt_id = (int) $wpdb->insert_id;
    22812285
Note: See TracChangeset for help on using the changeset viewer.