Make WordPress Core

Ticket #34626: 34626.patch

File 34626.patch, 2.8 KB (added by barryceelen, 10 years ago)
  • wp-includes/taxonomy-functions.php

    From 5bc53c066fe1c311e84a332e700dffa216b08e8f Mon Sep 17 00:00:00 2001
    From: Barry Ceelen <b@rryceelen.com>
    Date: Mon, 9 Nov 2015 00:04:43 +0100
    Subject: [PATCH 1/2] Delete term meta when deleting a term
    
    ---
     wp-includes/taxonomy-functions.php | 6 +++++-
     1 file changed, 5 insertions(+), 1 deletion(-)
    
    diff --git a/wp-includes/taxonomy-functions.php b/wp-includes/taxonomy-functions.php
    index 174fe74..e916e44 100644
    a b function wp_delete_object_term_relationships( $object_id, $taxonomies ) { 
    20522052 * Removes a term from the database.
    20532053 *
    20542054 * If the term is a parent of other terms, then the children will be updated to
    2055  * that term's parent.
     2055 * that term's parent. Meta fields associated with the term are deleted.
    20562056 *
    20572057 * The `$args` 'default' will only override the terms found, if there is only one
    20582058 * term found. Any other and the found terms are used.
    function wp_delete_term( $term, $taxonomy, $args = array() ) { 
    21722172        foreach ( $tax_object->object_type as $object_type )
    21732173                clean_object_term_cache( $objects, $object_type );
    21742174
     2175        $term_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $tt_id ));
     2176        foreach ( $term_meta_ids as $mid )
     2177                delete_metadata_by_mid( 'term', $mid );
     2178
    21752179        /**
    21762180         * Fires immediately before a term taxonomy ID is deleted.
    21772181         *
  • wp-includes/meta-functions.php

    -- 
    2.6.0
    
    
    From a00a78135ee4ebec2fa8f78c27d2607e19400cf4 Mon Sep 17 00:00:00 2001
    From: Barry Ceelen <b@rryceelen.com>
    Date: Mon, 9 Nov 2015 00:05:24 +0100
    Subject: [PATCH 2/2] Update code comment
    
    ---
     wp-includes/meta-functions.php | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/wp-includes/meta-functions.php b/wp-includes/meta-functions.php
    index be7ad5b..14e8af3 100644
    a b function metadata_exists( $meta_type, $object_id, $meta_key ) { 
    558558 *
    559559 * @global wpdb $wpdb WordPress database abstraction object.
    560560 *
    561  * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
     561 * @param string $meta_type Type of object metadata is for (e.g., comment, post, meta, or user)
    562562 * @param int    $meta_id   ID for a specific meta row
    563563 * @return object|false Meta object or false.
    564564 */
    function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = 
    692692 *
    693693 * @global wpdb $wpdb WordPress database abstraction object.
    694694 *
    695  * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
     695 * @param string $meta_type Type of object metadata is for (e.g., comment, post, term, or user)
    696696 * @param int    $meta_id   ID for a specific meta row
    697697 * @return bool True on successful delete, false on failure.
    698698 */