WordPress.org

Make WordPress Core

Ticket #35213: 35213.diff

File 35213.diff, 2.7 KB (added by obenland, 4 years ago)
  • src/wp-includes/taxonomy.php

     
    21582158        // Get the term before deleting it or its term relationships so we can pass to actions below.
    21592159        $deleted_term = get_term( $term, $taxonomy );
    21602160
    2161         $objects = $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) );
     2161        $object_ids = (array) $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) );
    21622162
    2163         foreach ( (array) $objects as $object ) {
    2164                 $terms = wp_get_object_terms($object, $taxonomy, array('fields' => 'ids', 'orderby' => 'none'));
     2163        foreach ( $object_ids as $object_id ) {
     2164                $terms = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids', 'orderby' => 'none' ) );
    21652165                if ( 1 == count($terms) && isset($default) ) {
    21662166                        $terms = array($default);
    21672167                } else {
     
    21702170                                $terms = array_merge($terms, array($default));
    21712171                }
    21722172                $terms = array_map('intval', $terms);
    2173                 wp_set_object_terms($object, $terms, $taxonomy);
     2173                wp_set_object_terms( $object_id, $terms, $taxonomy );
    21742174        }
    21752175
    21762176        // Clean the relationship caches for all object types using this term.
    21772177        $tax_object = get_taxonomy( $taxonomy );
    21782178        foreach ( $tax_object->object_type as $object_type )
    2179                 clean_object_term_cache( $objects, $object_type );
     2179                clean_object_term_cache( $object_ids, $object_type );
    21802180
    21812181        $term_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $term ) );
    21822182        foreach ( $term_meta_ids as $mid ) {
     
    22182218         * @param string  $taxonomy     Taxonomy slug.
    22192219         * @param mixed   $deleted_term Copy of the already-deleted term, in the form specified
    22202220         *                              by the parent function. WP_Error otherwise.
     2221         * @param array   $object_ids   List of term object IDs.
    22212222         */
    2222         do_action( 'delete_term', $term, $tt_id, $taxonomy, $deleted_term );
     2223        do_action( 'delete_term', $term, $tt_id, $taxonomy, $deleted_term, $object_ids );
    22232224
    22242225        /**
    22252226         * Fires after a term in a specific taxonomy is deleted.
     
    22332234         * @param int     $tt_id        Term taxonomy ID.
    22342235         * @param mixed   $deleted_term Copy of the already-deleted term, in the form specified
    22352236         *                              by the parent function. WP_Error otherwise.
     2237         * @param array   $object_ids   List of term object IDs.
    22362238         */
    2237         do_action( "delete_$taxonomy", $term, $tt_id, $deleted_term );
     2239        do_action( "delete_$taxonomy", $term, $tt_id, $deleted_term, $object_ids );
    22382240
    22392241        return true;
    22402242}