[wp-trac] [WordPress Trac] #53152: wp_set_object_terms ampersand in term name

WordPress Trac noreply at wordpress.org
Sun Aug 15 09:22:11 UTC 2021


#53152: wp_set_object_terms ampersand in term name
-------------------------------------------------+-------------------------
 Reporter:  kapacity                             |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Administration                       |     Version:  5.7.1
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests dev-        |     Focuses:
  feedback                                       |
-------------------------------------------------+-------------------------
Changes (by costdev):

 * keywords:  has-patch has-unit-tests => has-patch has-unit-tests dev-
     feedback


Comment:

 The
 [https://developer.wordpress.org/reference/functions/wp_set_object_terms/
 Docs] don't include the term name as a valid value for the `$terms`
 argument.

 However, passing the term name as the value ''will'' either match an
 existing term, or create a new term if `wp_set_object_terms()` is unable
 to find a match.

 The patch resolves this ticket's issue with the existing functionality,
 but I'm not sure if:

 * nothing should be done
 * the issue should be closed due to incorrect usage of the function
 (although, we can be sure this isn't the only time that the term name has
 been/will be passed)
 * the docs should be updated to mention the term name as a valid value
 * or `wp_set_object_terms()` should be locked down a bit more - possibly
 with an error if `is_string( $term ) && sanitize_title( $term ) !== $term`
 to rule out non-slug string values - a breaking change for existing sites
 that pass the term name

 If it's the latter, `wp_remove_object_terms()` may need to be updated too.
 I can open another ticket and look into this if this is the best
 direction.

 It would be great if a dev could give some guidance on how to proceed with
 this.

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


More information about the wp-trac mailing list