WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#6523 closed defect (bug) (invalid)

get_terms() bug

Reported by: Denis-de-Bernardy Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.5
Component: General Keywords:
Focuses: Cc:

Description

This plugin:

http://wordpress.org/extend/plugins/my-category-order/installation/

requires that one change the taxonomy.php file...

because there's a missing case in get_terms()

Change History (6)

comment:1 @Denis-de-Bernardy7 years ago

it should go like this:

	if ( 'count' == $orderby )
		$orderby = 'tt.count';
	else if ( 'name' == $orderby )
		$orderby = 't.name';
	else if ( 'slug' == $orderby )
		$orderby = 't.slug';
	else if ( 'term_group' == $orderby )
		$orderby = 't.term_group';
	else if ( 'term_order' == $orderby )
		$orderby = 'tr.term_order';
	else
		$orderby = 't.term_id';

(the term_order case is missing)

comment:2 @lloydbudd7 years ago

Denis-de-Bernardy, are you able to attach patches? Please see http://codex.wordpress.org/Reporting_Bugs#Patching_Bugs

comment:3 @Denis-de-Bernardy7 years ago

I'm afraid not... I run a customized version of WP and I've set up a dedicated svn for it. The patches I can generate won't work any more with your svn than the ones you're generating on mine. In the future, I'll try to set it up with WP as an external reference. Until then, I'm stuck with reporting bugs and findings. ;-)

Speaking of which, the above fix is not the only necessary change. The My Category Order plugin doesn't work as documented. There's a db query beneath the above code in get_terms() that also needs an extra table to avoid DB errors. And then, you get duplicate results all over the place.

I stopped looking into the issue upon getting the latter, as I had more important stuff to care about at the moment.

Still, the WP DB schema has a term_order field that is just asking to become useful. Maybe the plugin's developer will come up with the fix?

D.

comment:4 @lloydbudd7 years ago

Denis-de-Bernardy, surely it's trivial to maintain a clean WordPress check out to create your patches verses. The core developers being able to see the colorized diffs makes it more likely that your fixes get incorporated quickly.

comment:5 @Otto427 years ago

  • Resolution set to invalid
  • Severity changed from major to normal
  • Status changed from new to closed

term_order is in the term_relationships table. Adding it to a possible order field for get_terms doesn't make any sense, because get_terms gets terms by taxonomy, not by a relationship with a post. The SELECT statement in get_terms does not even include a JOIN to the term_relationships table or a reference to it as "tr".

Marking this as invalid, because it makes no sense.

comment:6 @lloydbudd7 years ago

  • Milestone 2.5.1 deleted
Note: See TracTickets for help on using tickets.