[wp-trac] [WordPress Trac] #39754: `_post_format_get_terms()` can overwrite names of terms in other taxonomies

WordPress Trac noreply at wordpress.org
Wed Feb 1 03:19:37 UTC 2017


#39754: `_post_format_get_terms()` can overwrite names of terms in other taxonomies
--------------------------+-----------------------------
 Reporter:  dlh           |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 `_post_format_get_terms()` filters `'get_terms'` and includes this logic:

 {{{
 if ( in_array( 'post_format', (array) $taxonomies ) ) {
         if ( isset( $args['fields'] ) && 'names' == $args['fields'] ) {
                 foreach ( $terms as $order => $name ) {
                         $terms[$order] = get_post_format_string(
 str_replace( 'post-format-', '', $name ) );
                 }
         }
 ...
 }}}

 which affects the names of all `$terms`, as long as `post_format` was one
 of the queried taxonomies. Many terms are replaced with an empty string
 from `get_post_format_string()`.

 The attached patch includes a test to demonstrate the issue, and it would
 check before changing a value that the value begins with `post-format-`
 and that `get_post_format_string()` returns a name for the value.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39754>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list