Posts, Post Types: Discard `tags_input` parameter in `wp_update_post()` if it's the same as existing post tags.
This ensures that `wp_update_post()` does not unintentionally modify post tags if the post has several tags with the same name but different slugs. Tags should only be modified if `tags_input` parameter was explicitly provided, and is different from the existing tags. Props kaggdesign, SergeyBiryukov. Fixes #45121. Built from https://develop.svn.wordpress.org/trunk@47317 git-svn-id: http://core.svn.wordpress.org/trunk@47115 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
548685b97d
commit
e67b01895b
|
@ -4217,6 +4217,20 @@ function wp_update_post( $postarr = array(), $wp_error = false ) {
|
|||
return wp_insert_attachment( $postarr, false, 0, $wp_error );
|
||||
}
|
||||
|
||||
// Discard 'tags_input' parameter if it's the same as existing post tags.
|
||||
if ( isset( $postarr['tags_input'] ) && is_object_in_taxonomy( $postarr['post_type'], 'post_tag' ) ) {
|
||||
$tags = get_the_terms( $postarr['ID'], 'post_tag' );
|
||||
$tag_names = array();
|
||||
|
||||
if ( $tags && ! is_wp_error( $tags ) ) {
|
||||
$tag_names = wp_list_pluck( $tags, 'name' );
|
||||
}
|
||||
|
||||
if ( $postarr['tags_input'] === $tag_names ) {
|
||||
unset( $postarr['tags_input'] );
|
||||
}
|
||||
}
|
||||
|
||||
return wp_insert_post( $postarr, $wp_error );
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.4-beta2-47313';
|
||||
$wp_version = '5.4-beta2-47317';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue