Make WordPress Core

Opened 16 months ago

Closed 15 months ago

Last modified 15 months 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:

Description

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 16 months ago.

Download all attachments as: .zip

Change History (7)

@david.binda
16 months ago

#1 @SergeyBiryukov
16 months ago

  • Milestone changed from Awaiting Review to 6.0

#2 follow-up: @azouamauriac
16 months 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 safely its second parameter "$taxonomy" in
update_term_cache.

Thanks.

Last edited 16 months ago by azouamauriac (previous) (diff)

#3 @azouamauriac
16 months ago

  • Keywords 2nd-opinion added

#4 in reply to: ↑ 2 @peterwilsoncc
15 months 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
update_term_cache.

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
15 months 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
15 months ago

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