Make WordPress Core

Opened 9 years ago

Closed 6 years ago

Last modified 5 years ago

#35173 closed defect (bug) (worksforme)

in_category function doesn't work after update to WP 4.4

Reported by: artemkolotilkin's profile artem.kolotilkin Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Taxonomy Keywords: reporter-feedback bulk-reopened
Focuses: Cc:

Description

After updating to WP 4.4 "in_category" function no longer works. I was able to trace the issue to "is_object_in_term" function:
https://github.com/WordPress/WordPress/blob/4.4/wp-includes/taxonomy.php#L4520

In that function "get_object_term_cache" returns empty array instead of correct terms from cache. Because it's an empty array and not false value, it doesn't try to load terms from DB, thus "in_category" function returns false, although term is assigned to a post.

Downgrading to WP 4.3.1 fixes the problem.

Change History (4)

#1 @boonebgorges
9 years ago

  • Keywords reporter-feedback added

Hi @artem.kolotilkin - Thanks for the report, and welcome to Trac!

The value returned by get_object_term_cache() should only by an empty array if some other function has set the {$taxonomy}_relationships cache to an empty array. Are you able to debug whether a plugin on your system is setting the relationships cache?

Possibly related: https://core.trac.wordpress.org/ticket/34723#comment:9 and the comments that follow.

#2 follow-up: @artem.kolotilkin
9 years ago

Hi @boonebgorges , thanks for looking into that. I've just confirmed that in_category function stops working after update to WP4.4. No other changes are done to the codebase.

I also tried to apply this patch [35851], but it didn't help.

Is there anything else I can check to figure this out?

Last edited 9 years ago by SergeyBiryukov (previous) (diff)

#3 in reply to: ↑ 2 @boonebgorges
9 years ago

Replying to artem.kolotilkin:

Hi @boonebgorges , thanks for looking into that. I've just confirmed that in_category function stops working after update to WP4.4. No other changes are done to the codebase.

I also tried to apply this patch (https://core.trac.wordpress.org/changeset/35851), but it didn't help.

Is there anything else I can check to figure this out?

If my guess is correct, then simply applying a patch is not going to demonstrate a fix. The problem is probably not is_object_in_term() itself. Instead, the problem is likely that some other part of the system (core or a plugin) is incorrectly caching an empty array, or perhaps some bit of cache is not being properly invalidated.

Are you running a persistent object cache backend? Memcached, Redis, etc. If so, are you able to replicate the problem when this backend is disabled.

Are you able to reproduce the problem on a fresh installation of WordPress?

Can you provide complete details on how to reproduce? Is it *all* uses of in_category()? Only those in theme templates? For all categories, or just specific categories? Within the loop or outside of it? Any details you can provide would be helpful.

#6 @boonebgorges
6 years ago

  • Keywords bulk-reopened added
  • Resolution set to worksforme
  • Status changed from new to closed

Closing due to lack of activity.

Note: See TracTickets for help on using tickets.