Opened 15 years ago
Closed 15 years ago
#3726 closed defect (bug) (fixed)
wp_list_categories() goes berzerk on default install with object cache enabled
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.1.1 | Priority: | highest omg bbq |
Severity: | major | Version: | 2.1 |
Component: | Template | Keywords: | |
Focuses: | Cc: |
Description
- New install of WP 2.1
- Published 4 posts in "Uncategorized" category.
define('ENABLE_CACHE', true);
inwp-config.php
- Load the front page
First run (non-cached) gives me:
<li class="categories"><h2>Categories</h2><ul> <li><a href="http://txfx.net/wp22/?cat=1" title="View all posts filed under Uncategorized">Uncategorized</a> (4) </li> </ul></li>
Perfect.
Second run (cached), gives me:
<li class="categories"><h2>Categories</h2><ul> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> <ul class="children"> </ul>
That ain't right.
Attachments (2)
Change History (9)
#1
@
15 years ago
I can't seem to confirm this... any other steps you may have missed?
Not that I don't think you know what version you were running but I couldn't help but notice the directory being labeled "wp22" (just checking ;))
#2
@
15 years ago
I did a svn switch to /branches/2.1/ before reporting.
In order for the cache to be enabled, your wp-contents directory needs to be writable (it should create a /cache/ directory).
In any case, I discovered the issue. get_category()
tries to store an array of object references into the cache. The cache doesn't like this, and stores a blank string instead. So you get a blank string on the way out.
Looking around the web, it seems like good old serialize/unserialize is the sure way to make sure you don't have any references. Patch adds that to the appropriate cache functions.
#4
@
15 years ago
- Milestone changed from 2.1.1 to 2.2
To explain this a bit:
- Two pseudo-options are stored in the object cache (just there, not in the DB)
- 'notoptions' stores all attempted non-options so that the DB isn't accessed more than once trying to load these options that don't exist
- 'alloptions' stores all autoloaded options. The first time any option is queried, 'alloptions' will be populated (either from the DB, or from a persistent object cache). If the option is in there (likely, most options are autoloaded), it'll be read from there. So you just have one cache read for all your autoloaded options.
- Non-autoloaded options revert to the options cache as before (one item per cache entry).
- Since the loading of the autoloaded options is used by get_option(), people using alternative object caches will no longer see individual queries for each option on the first load (i.e. with an empty object cache)
All of this should be transparent. As long as you use get_option(), add_option(), update_option(), and delete_option(), it should be like nothing ever happened.
This should reduce cache misses to zero (or close to it), and it should reduce redundant queries.
screenshot of result