#47745 closed defect (bug) (wontfix)
get_term will send back term_id as string if $filter = 'edit'. Use of 'edit' causes issues with hooks in edit-tag-form passing a non-conforming WP_Term object as $tag
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | |
Focuses: | administration | Cc: |
Description
The file "edit-tag-form.php" contains multiple hooks that pass $tag as an argument.
Within each of these hooks the $tag->term_id type is string
.
using this as a test against a vanilla 5.2.2 & trunk site (theme: twentynineteen, plugins: none... not even akismet and hello).
add_action( 'edit_category_form_fields', 'test_category_term_id_type' );
function test_category_term_id_type( $tag ) {
error_log( gettype( $tag->term_id ) );
}
[21-Jul-2019 00:04:41 UTC] string
$tag
is set in term.php
using get_term
using the filter 'edit'
within the get_term()
method $_term
is filtered by edit
which then utilizes sanitize_term()
which passes the term object through sanitize_term_field
which uses $context='edit'
.
Within sanitize_term_field if $context='edit'
the field is passed through esc_attr()
.
esc_attr()
immediately casts the value sent to it to (string)
and then returns it.
Other places where edit
is used as a filter in core for get_term
:
class-wp-terms-list-table.php | column_name()
taxonomy.php | get_category_to_edit()
Hi Majemedia. Thanks for the ticket. I just wanted to double-check that the issue you're referring to is that
term_id
is astring
instead of anumber
? Is that causing any specific issues for you?term_id
being a string is a known issue. Unfortunately changing this would break backwards compatibility.