wp-cache
Opened 11 years ago
Last modified 11 years ago
#2296 new defect
WP Super Cache does not clear category and tag pages in some cases
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Severity: | normal |
| Plugin: | wp-cache | Keywords: | |
| Cc: |
Description
I have a WordPress installation using these settings:
permalink_structure: /posts/%postname%/
category_base: /category/
tag_base: <no value>
WP Super Cache doesn't clear the cached page for a matching tag when I publish a new post with that tag, although it does clear the categories.
I've traced the problem to the "wpsc_delete_cats_tags" function in wp-cache-phase2.php:
$tag_base = get_option( 'tag_base' );
if ( $tag_base == '' )
$tag_base = '/tag/';
This isn't right: on my system, the correct path begins with "/posts/tag/". The difference means that wpsc_delete_cats_tags() doesn't find and delete the obsolete tag file.
In "wp-includes/rewrite.php", there's documentation for get_tag_permastruct() that says:
- If the tag_base property has no value, then the tag structure will have
- the front property value, followed by 'tag', and finally '%tag%'. If it
- does, then the root property will be used, along with the tag_base
- property value.
Note that it says it first begins with the "front property value" -- that is, the first part of the posts permalink ("/posts/" in my case). It's not necessarily just "/tag/".
(I think that documentation might be slightly wrong, because when I call get_tag_permastruct, what I get back ends in "%post_tag%", not "%tag%". But that's unrelated to the problem at hand.)
There's similar code for categories:
$category_base = get_option( 'category_base');
if ( $category_base == '' )
$category_base = '/category/';
... but I wasn't affected by this because I have category_base set.
Perhaps these could be replaced with code that calls $wp_rewrite->get_tag_permastruct() and $wp_rewrite->get_category_permastruct), then does a str_replace to remove the trailing "%post_tag%" and "%category%"?