Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#55162 closed defect (bug) (fixed)

Incorrect parameter passed to update_term_cache from _prime_term_caches

Reported by: davidbinda's profile david.binda Owned by: peterwilsoncc's profile peterwilsoncc
Milestone: 6.0 Priority: normal
Severity: normal Version: 4.6
Component: Taxonomy Keywords: has-patch
Focuses: Cc:


The update_term_cache function has a deprecated parameter string $taxonomy, which is not used. the _prime_term_caches function
is calling the update_term_cache while passing in it's own parameter $update_meta_cache, which is of a boolean type, and has nothing to do with taxonomy.

As the update_term_cache has deprecated the $taxonomy parameter, there is no harm in passing in the bool value as second argument, but it makes the code less readable, as it's clearly wrong.

It seems like it has been that way since introduction in r37573

From my point of view, the _prime_term_caches should be calling the update_term_cache function with a single argument.

Attachments (1)

55162.diff (677 bytes) - added by david.binda 2 years ago.

Download all attachments as: .zip

Change History (7)

2 years ago

#1 @SergeyBiryukov
2 years ago

  • Milestone changed from Awaiting Review to 6.0

#2 follow-up: @azouamauriac
2 years ago

  • Keywords has-patch added

Hello thanks for your report, after some deeply search the $taxonomy seems to become unused here [34999].

Also it seems like _prime_term_caches is the only function which uses update_term_cache with the second parameter, so I think we can remove its second parameter we can remove safely "$taxonomy" in


Version 0, edited 2 years ago by azouamauriac (next)

#3 @azouamauriac
2 years ago

  • Keywords 2nd-opinion added

#4 in reply to: ↑ 2 @peterwilsoncc
2 years ago

Replying to azouamauriac:

Also it seems like _prime_term_caches is the only function which uses update_term_cache with the second parameter, so I think we can remove safely its second parameter "$taxonomy" in

WordPress tends to keep the deprecated parameters listed to future proof against any upcoming changes:

fn( $string, $object, $array ) might have the final argument deprecated fn( $string, $object, $deprecated ). The deprecated parameter needs to be keep as a placeholder in case a new parameter is added at a later date, eg fn( $string, $object, $deprecated, $boolean )

There's a little judgement involved each time.

However, it doesn't look like the $taxonomy argument was formally deprecated in update_term_cache() so perhaps you could look at that on another ticket.

#5 @peterwilsoncc
2 years ago

  • Owner set to peterwilsoncc
  • Resolution set to fixed
  • Status changed from new to closed

In 52830:

Taxonomy: Improve code quality within _prime_term_caches().

Remove the second parameter on the call to update_term_cache() from within the function _prime_term_caches(). The since deprecated parameter of the former was at one point a string, never a boolean.

Props david.binda, SergeyBiryukov, azouamauriac.
Fixes #55162.

#6 @azouamauriac
2 years ago

  • Keywords 2nd-opinion removed
Note: See TracTickets for help on using tickets.