WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 4 months ago

#18828 new defect (bug)

function wp_get_object_terms() passes sql data into `wp_get_object_terms` filter for $taxonomies

Reported by: postpostmodern Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 2.8
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

Description

In wp-includes/taxonomy.php, the return data is passed through the wp_get_object_terms filter using the sql-ready data for $taxonomies, meaning it is quoted and comma seperated, for example "'category', 'post_tag', 'post_format'". Even for one taxonomy, it has quotes added, it seems this would be easier to work with if it matched the data passed into the function more closely.

Attachments (1)

wp_get_object_terms.diff (2.1 KB) - added by postpostmodern 3 years ago.
function wp_get_object_terms() fixing $taxonomy for filter

Download all attachments as: .zip

Change History (7)

postpostmodern3 years ago

function wp_get_object_terms() fixing $taxonomy for filter

comment:1 ryan3 years ago

An array would indeed be better, but we need to see how many plugins this change impacts.

comment:2 nacin2 years ago

  • Keywords 3.4-early added
  • Milestone changed from Awaiting Review to Future Release
  • Version changed from 3.3 to 3.2

comment:3 wonderboymusic8 months ago

  • Milestone changed from Future Release to 3.7

Let's figure out if we can do this

comment:4 follow-ups: nacin7 months ago

  • Milestone changed from 3.7 to Future Release

We need to figure out:

  • If any plugins are using the wp_get_object_terms filter, and what they do when they handle $taxonomies.
  • When we broke this, or if it was always like this.

comment:5 in reply to: ↑ 4 jdgrimes5 months ago

  • Keywords 3.4-early removed
  • Version changed from 3.2 to 2.8

Replying to nacin:

We need to figure out:

  • If any plugins are using the wp_get_object_terms filter, and what they do when they handle $taxonomies.
  • When we broke this, or if it was always like this.

It appears that the taxonomies have been passed like this since the filter was first introduced in [11253].

comment:6 in reply to: ↑ 4 postpostmodern4 months ago

Replying to nacin:

We need to figure out:

  • If any plugins are using the wp_get_object_terms filter, and what they do when they handle $taxonomies.
  • When we broke this, or if it was always like this.

As far as I can tell, this affects two plugins in the plugins directory.

Custom Taxonomy Sort This plugin has not been updated in over two years. The method get_terms in http://plugins.trac.wordpress.org/browser/custom-taxonomy-sort/trunk/custom-taxonomy-sort.php uses this as the $taxonomy argument and ignores it.

The other plugin that uses this is Co-Authors Plus. The method filter_wp_get_object_terms in http://plugins.trac.wordpress.org/browser/co-authors-plus/trunk/co-authors-plus.php uses this data in the way WordPress is currently built, directly inserted into a manual sql query. However, this plugin is authored by Core contributors and could easily be updated, and as it is only tested to 3.5.2 it is due to be checked for compatibility anyways.

I would argue that using $taxonomies as an array in this filter is still better and more flexible to work with, a use case would be removing or inserting specific taxonomies into this data.

Last edited 4 months ago by postpostmodern (previous) (diff)
Note: See TracTickets for help on using tickets.