When deleting a term, delete its metadata as well.

Props barryceelen.
Fixes #34626.
Built from https://develop.svn.wordpress.org/trunk@35585


git-svn-id: http://core.svn.wordpress.org/trunk@35549 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2015-11-09 03:36:26 +00:00
parent f4659f7ee0
commit 545124ffb3
3 changed files with 10 additions and 3 deletions

View File

@ -558,7 +558,7 @@ function metadata_exists( $meta_type, $object_id, $meta_key ) {
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
* @param string $meta_type Type of object metadata is for (e.g., comment, post, meta, or user).
* @param int $meta_id ID for a specific meta row
* @return object|false Meta object or false.
*/
@ -692,7 +692,7 @@ function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key =
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
* @param string $meta_type Type of object metadata is for (e.g., comment, post, term, or user).
* @param int $meta_id ID for a specific meta row
* @return bool True on successful delete, false on failure.
*/

View File

@ -2054,6 +2054,8 @@ function wp_delete_object_term_relationships( $object_id, $taxonomies ) {
* If the term is a parent of other terms, then the children will be updated to
* that term's parent.
*
* Metadata associated with the term will be deleted.
*
* The `$args` 'default' will only override the terms found, if there is only one
* term found. Any other and the found terms are used.
*
@ -2172,6 +2174,11 @@ function wp_delete_term( $term, $taxonomy, $args = array() ) {
foreach ( $tax_object->object_type as $object_type )
clean_object_term_cache( $objects, $object_type );
$term_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $term ) );
foreach ( $term_meta_ids as $mid ) {
delete_metadata_by_mid( 'term', $mid );
}
/**
* Fires immediately before a term taxonomy ID is deleted.
*

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-beta3-35584';
$wp_version = '4.4-beta3-35585';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.