[wp-trac] [WordPress Trac] #45121: wp_update_post() can modify post tag

WordPress Trac noreply at wordpress.org
Wed Feb 19 01:39:44 UTC 2020


#45121: wp_update_post() can modify post tag
---------------------------------------------+-----------------------------
 Reporter:  kaggdesign                       |       Owner:  SergeyBiryukov
     Type:  defect (bug)                     |      Status:  reviewing
 Priority:  normal                           |   Milestone:  5.4
Component:  Posts, Post Types                |     Version:  4.9.8
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch has-unit-tests commit  |     Focuses:
---------------------------------------------+-----------------------------
Changes (by SergeyBiryukov):

 * keywords:  has-patch has-unit-tests needs-refresh => has-patch has-unit-
     tests commit


Comment:

 [attachment:"wp_update_post.diff"] does solve the reported problem, but it
 also prevents any modification of post tags via the `tags_input`
 parameter, even if it's intentional.

 Something along the lines of [31359] seemed like it might work, however in
 practice it doesn't, since the `tags_input` value returned by
 [source:tags/5.3.2/src/wp-includes/class-wp-post.php?marks=323-333#L306
 WP_Post::__get()] contains tag names, and if they are the same, there's no
 way to disambiguate them at that point.

 I think the correct solution here would be to disregard the `tags_input`
 parameter if it's the same as existing post tags. That way tags are only
 modified if `tags_input` was explicitly provided, and is different from
 the existing tags.

 See [attachment:"45121.2.diff"].

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45121#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list