WordPress.org

Make WordPress Core

Opened 16 months ago

Closed 16 months ago

Last modified 15 months ago

#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: majemedia 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()

Change History (3)

#1 @talldanwp
16 months ago

  • Keywords reporter-feedback added; dev-feedback needs-dev-note removed

Hi Majemedia. Thanks for the ticket. I just wanted to double-check that the issue you're referring to is that term_id is a string instead of a number? Is that causing any specific issues for you?

term_id being a string is a known issue. Unfortunately changing this would break backwards compatibility.

#2 @majemedia
16 months ago

  • Resolution set to wontfix
  • Status changed from new to closed

@talldanwp That is the issue I was referring to.

I'll resolve as wontfix due to the backwards compatibility issue.

#3 @desrosj
15 months ago

  • Focuses administration added; coding-standards removed
  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Version trunk deleted
Note: See TracTickets for help on using tickets.