[wp-trac] [WordPress Trac] #38310: Improve "wp_update_term" documentation

WordPress Trac noreply at wordpress.org
Sun Oct 30 20:04:17 UTC 2016


#38310: Improve "wp_update_term" documentation
--------------------------------------+-----------------------------
 Reporter:  ruud@…                    |       Owner:
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  Future Release
Component:  Taxonomy                  |     Version:  trunk
 Severity:  normal                    |  Resolution:
 Keywords:  good-first-bug has-patch  |     Focuses:  docs
--------------------------------------+-----------------------------

Comment (by ruud@…):

 Hi Boone and Mazzomaz,

 @boonebgorges, Thanks for thorough description and the clear instructions
 on how to move this ticket forward
 @mazzomaz, Thanks for the patch, removing the paragraph is for the better.

 However, while digging through this lengthy function, and thinking of the
 double 'warning' in the inline-docs =>
 1. 'Care must be taken to not override important information need to
 update or update will fail (or perhaps create a new term, neither would be
 acceptable).'
 2. 'check the term scheme can contain and stay away from the term keys.'

 I thought why bother with all these 'warnings' while we can just
 circumvent (un)intentional by removing the term_id from the $args.

 Example: not removing the 'term_id' from $args will result in getting a
 slug from the wrong Term

 $slug = wp_unique_term_slug($slug, (object) $args) => $query =
 $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id
 != %d", $slug, $term->term_id );

 If the 'term_id' is missing and/or removed the sanitize_term() function
 will correct this anyway to its default, but after the array_merge( $term,
 $args ) which I think is important for not overwriting the original
 term_id.

 Disclaimer: I do not know any of the background of this function, or it's
 use in the broader WP eco-system. So please let me know if this patch
 doesn't make sense at all.

 Thanks,
 Ruud

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


More information about the wp-trac mailing list