Opened 8 years ago
Closed 8 years ago
#37205 closed defect (bug) (fixed)
Shared term's edit screen is inaccessible
Reported by: | dlh | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | 4.5 |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | administration | Cc: |
Description
term.php
populates $tag
by calling get_term()
without a $taxonomy
. If the term ID being edited is still shared, then that get_term()
call will return an 'ambiguous_term_id'
error, which leads to wp_die()
.
Per ticket:34988#comment:10, term.php
assumes there are no shared terms, so this might be an invalid report. I can understand if, by this point, core considers shared terms to be edge cases at most.
Technically, the error message ("You attempted to edit an item that doesn't exist") is also inaccurate. I can't think of a user-friendly description for it, though.
Attachments (1)
Change History (8)
#1
@
8 years ago
- Keywords has-patch added
I agree with David -- I understand if this feels like a Wile E. Coyote edge case, but it also is a real live production issue on a couple of sites and seems like a pretty harmless backwards compatibility patch.
This ticket was mentioned in Slack in #core by dlh. View the logs.
8 years ago
#4
@
8 years ago
- Keywords dev-feedback added
- Milestone changed from Awaiting Review to 4.6
Thinking through this issue. $taxnow
was removed from the call to get_term()
in term.php in [36874]. The commit message suggests that the taxonomy context should be set in WP_Screen
, but I don't fully understand how this is the case - get_term()
doesn't reference the current screen anywhere.
The fix suggested in 37205.2.diff (which is too verbose - $taxnow
falls back on 'post_tag', so is never empty) depends on the ?taxonomy
query arg being set when visiting term.php. This is in fact the case when coming from edit-tags.php, which I think is the main path into term.php.
Passing $taxnow
into get_term()
seems harmless as far as I can see, but I'd like a confirmation from @swissspidy (author of [36874]) before going forward with it.
#5
@
8 years ago
- Keywords dev-feedback removed
Thanks for pinging me!
The commit message suggests that the taxonomy context should be set in
WP_Screen
, but I don't fully understand how this is the case -get_term()
doesn't reference the current screen anywhere.
wp-admin/admin.php
calls set_current_screen()
, which in turn calls WP_Screen::get()
. [36874] made sure that inside that method $taxonomy
, $post_type
and the screen ID are properly populated.
The fix suggested in 37205.2.diff (which is too verbose -
$taxnow
falls back on 'post_tag', so is never empty) depends on the?taxonomy
query arg being set when visiting term.php. This is in fact the case when coming from edit-tags.php, which I think is the main path into term.php.
The $taxonomy
variable inside WP_Screen::get()
falls back to post_tag
, but not $taxnow
, which is being set in wp-admin/admin.php
and defaults to an empty string.
Therefore replacing get_term( $tag_ID, '', OBJECT, 'edit' );
with get_term( $tag_ID, $taxnow, OBJECT, 'edit' );
should be enough. Definitely makes sense to me.
Shared term backward compatibility for term.php