Make WordPress Core

Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#3427 closed defect (bug) (invalid)

$category_cache format change (regression?)

Reported by: alexkingorg's profile alexkingorg Owned by: markjaquith's profile markjaquith
Milestone: Priority: highest omg bbq
Severity: blocker Version: 2.1
Component: General Keywords:
Focuses: Cc:


In 2.0.x, $category_cache is an array of post_id arrays with category objects as the post_id array values.

Array (

'post_id' => array(category_object, category_object)
,'post_id' => array(category_object)


In 2.1 there seems to have been another layer of array added:

Array (

Array (

'post_id' => Array(category_object, category_object)
,'post_id' => Array(category_object)



I can't see the benefit of this extra layer, and it breaks backward compatibility.

If this is "broken" as I suspect, point me in the right direction and I'll try to create a patch.

Change History (7)

#1 @markjaquith
17 years ago

  • Owner changed from anonymous to markjaquith
  • Status changed from new to assigned

Looks like that changed here: [4524], and it looks like it was intentional. I can't think of a clean way to fix backward compat (and keep this change) off the top of my head. We could have two cache vars (one for 1, one for non-1), but that's ugly.

'course, we're already breaking some backwards compat with 2.1, so better to break many things at once instead of a little at a time.


#2 @ryan
17 years ago

The caches are not really public. Do we not have API for what you want to do?

#3 @markjaquith
17 years ago

  • Milestone 2.1 deleted
  • Resolution set to invalid
  • Status changed from assigned to closed

Actually, yes, now that I look, there appears to be API for everything that's changed. I was thinking of the $comment_count_cache which doesn't have an API, but hasn't changed.

Alex, unless you can come up with a case where the current API for these isn't sufficient (get_category(), get_post() etc and wp_cache_set()), I think this can be closed.

#4 @alexkingorg
17 years ago

Take a look at what I'm doing here:

Line 100-125 or so. I need to loop through the post/cat relationships. I'm trying to use the tools given to me by core, but making the plugin be 2.0.x and 2.1.x compatible is a bit tricky.

I'm not sure how the APIs help here. What would really help would be to have an array of categories as a property of each post, but I think I've rung that bell to death already. :)

#5 @ryan
17 years ago

Maybe we can change wp_get_post_categories() to use $category_cache. Would that help?

#6 @alexkingorg
17 years ago

Yes, that sounds like a decent work-around. Should I open a new ticket for this?

#7 @ryan
17 years ago

Yes. Let's leave this one closed and open a new one for wp_get_post_categories().

Note: See TracTickets for help on using tickets.