[wp-trac] [WordPress Trac] #37378: 4.6 breaks tax query alterations (i.e. INNER_JOIN)
WordPress Trac
noreply at wordpress.org
Sat Jul 16 00:16:15 UTC 2016
#37378: 4.6 breaks tax query alterations (i.e. INNER_JOIN)
--------------------------+-----------------------------
Reporter: nimmolo | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: trunk
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
It seems altering the tax query $pieces['join'] or $pieces['orderby'] is
breaking the query.
The following function is from repository plugin
[https://wordpress.org/plugins/simple-taxonomy-ordering/ Simple Taxonomy
Ordering]. The plugin function works in 4.5.3., no errors.
{{{#!php
<?php
/*
* Re-Order the taxonomies based on the tax_position value
* @since 0.1
*/
public function yikes_alter_tax_order( $pieces, $taxonomies, $args ) {
foreach( $taxonomies as $taxonomy ) {
// confirm the tax is set to hierarchical -- else do not
allow sorting
if( $this->yikes_is_taxonomy_position_enabled( $taxonomy )
) {
global $wpdb;
$pieces['join'] .= " INNER JOIN $wpdb->termmeta AS
term_meta ON t.term_id = term_meta.term_id";
$pieces['orderby'] = "ORDER BY
term_meta.meta_value";
}
}
return $pieces;
}
}}}
Throws this error message:
`WordPress database error You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax
to use near 'ORDER BY term_meta.meta_value ASC' at line 1 for query SELECT
t.*, tt.* FROM wp_fv47w7_terms AS t INNER JOIN wp_fv47w7_term_taxonomy AS
tt ON t.term_id = tt.term_id INNER JOIN wp_fv47w7_termmeta AS term_meta ON
t.term_id = term_meta.term_id WHERE tt.taxonomy IN ('category') ORDER BY
ORDER BY term_meta.meta_value ASC made by WP_List_Table->display,
WP_Terms_List_Table->display_rows_or_placeholder, get_terms,
WP_Term_Query->query, WP_Term_Query->get_terms`
Is the syntax in fact incorrect?
I'm not great with query syntax, but if incorrect it seems it would have
thrown the error in WP 4.5.3
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37378>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list