Opened 8 years ago
Closed 8 years ago
#39388 closed defect (bug) (invalid)
Can't delete tags under custom taxonomies
Reported by: | contempoinc | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.7 |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
Description
Simple one custom you can't delete tags under custom taxonomies, once you've clicked the "X" update the post the tag come right back.
Change History (15)
#4
@
8 years ago
- Milestone changed from Awaiting Review to 4.7.2
Hey @contempoinc
Can you please clarify the issue you're seeing?
Which X are you referring to?
In my testing deleting terms both via a custom term page (Menu -> Post type -> Taxonomy) and removing it from a post works via the edit post screen.
Are you able to post an example register_taxonomy()
call which can register a taxonomy which reproduces this?
I'm tentatively marking this as 4.7.2, pending reproducibility.
#6
@
8 years ago
After investigating, I cannot call this an issue.
I believe you are in a post, click x on a tag, and are not clicking update? I can confirm that in both version 4.6.1 and 4.7.2 I am required to click update in order for the delete to process. And the functionality is the same between default and custom taxonomies.
Can anyone reproduce?
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
8 years ago
#8
@
8 years ago
- Milestone 4.7.3 deleted
- Resolution set to worksforme
- Status changed from new to closed
Hi @contempoinc I'm marking this as worksforme
as a few of us have been unable to verify the problem.
If you can post some more details which can be used to duplicate the issue on a clean install please do so and re-open the ticket.
#9
follow-up:
↓ 10
@
8 years ago
- Resolution worksforme deleted
- Status changed from closed to reopened
This is the error I'm seeing, and again this only happened after WP 4.7+
[07-Mar-2017 17:00:12 UTC] 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 '* 1 ASC' at line 1 for query SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('beds') AND tr.object_id IN (1792) ORDER BY * 1 ASC made by edit_post, wp_update_post, wp_insert_post, wp_set_post_terms, wp_set_object_terms, wp_get_object_terms, get_terms, WP_Term_Query->query, WP_Term_Query->get_terms [07-Mar-2017 17:00:12 UTC] 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 '* 1 ASC' at line 1 for query SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('baths') AND tr.object_id IN (1792) ORDER BY * 1 ASC made by edit_post, wp_update_post, wp_insert_post, wp_set_post_terms, wp_set_object_terms, wp_get_object_terms, get_terms, WP_Term_Query->query, WP_Term_Query->get_terms
#10
in reply to:
↑ 9
@
8 years ago
Replying to contempoinc:
These are the two errors I'm seeing, and again this only happened after WP 4.7+
Are you able to post the arguments you're passing to register_taxonomy()
to aid with reproduction?
#11
@
8 years ago
Super simple, same I'm using for all my others as well could it be an issue that they're plural, maybe some sort of conflict with an update made in WP 4.7+?
<?php // Beds register_taxonomy( 'beds', 'listings', array( 'hierarchical' => false, 'labels' => $bedslabels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'bed' ), )); // Baths register_taxonomy( 'baths', 'listings', array( 'hierarchical' => false, 'labels' => $bathslabels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'bath' ), ));
#12
@
8 years ago
- Milestone set to Awaiting Review
@contempoinc I also can't reproduce the error.
Are you running any plugins or other modifications using the 'terms_clauses' or 'get_terms_orderby' filter? Prior to WP 4.7, these filters didn't run during wp_get_object_terms()
, which may explain why you're seeing your problem only in 4.7+. Looking at the malformed SQL you've posted, I'm guessing that a plugin is doing some overzealous string manipulation via one of these filters. (The ORDER BY
clause is tightly controlled with a whitelist, so it's impossible for ORDER BY * 1
to appear except by these filters, or perhaps a more generic filter like 'query'
. It doesn't appear possible for this syntax to be generated by WordPress itself.)
#13
@
8 years ago
That was it, I do use the functions below on the frontend to order beds and baths with get_terms_orderby, I removed them and I'm able to delete the duplicates can you recommend a way to get this tweaked to work in 4.7+?
<?php /*-----------------------------------------------------------------------------------*/ /* Order Beds by Number */ /*-----------------------------------------------------------------------------------*/ if(!function_exists('beds_terms_order_as_number')) { function beds_terms_order_as_number($order_by, $args, $taxonomies){ $taxonomy_to_sort = "beds"; if(in_array($taxonomy_to_sort, $taxonomies)){ $order_by .= " * 1"; } return $order_by; } } add_filter( 'get_terms_orderby', 'beds_terms_order_as_number', 10, 3); /*-----------------------------------------------------------------------------------*/ /* Order Baths by Number */ /*-----------------------------------------------------------------------------------*/ if(!function_exists('baths_terms_order_as_number')) { function baths_terms_order_as_number($order_by, $args, $taxonomies){ $taxonomy_to_sort = "baths"; if(in_array($taxonomy_to_sort, $taxonomies)){ $order_by .= " * 1"; } return $order_by; } } add_filter( 'get_terms_orderby', 'baths_terms_order_as_number', 10, 3);
#15
@
8 years ago
- Keywords reporter-feedback removed
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from reopened to closed
Thanks for confirming.
I'm not 100% sure what your filter is meant to do, but a simple workaround for this specific issue is to refrain from modifying the query if 'object_ids' is detected:
function beds_terms_order_as_number($order_by, $args, $taxonomies){ if ( ! empty( $args['object_ids'] ) ) { return $order_by; } // ...
Thanks for the report!
I suspect this is related to #39328, I'll confirm over the holiday period.
Are you able to check whether this happens both with & without any plugins running?