Automattic / Automattic/wp-super-cache

Invalid $blogcacheid value for multisite installs within a subdirectory

Open
#861 0 comments 0 reactions 0 assignees View on GitHub
[Plugin] Super Cache bug
Dominant language
PHP
Stars
436
Forks
130
Avg merge
15h 11m
Merged PRs (30d)
10

Description

Hello,

we have a wordpress multisite installation within a subdirectory which results in urls like https://domain/blog/blog1/ and https://domain/blog/blog2 and so on.

The following code is located in wp-cache-base.php and assigns the $blogcacheid variable with values like "blog/blog1" or "blog/blog2".

`if ( is_object( $current_blog ) && function_exists( 'is_subdomain_install' ) ) {
$blogcacheid = is_subdomain_install() ? $current_blog->domain : trim( $current_blog->path, '/' );
}`

In wp-cache-phase2.php the built cache files are then renamed to their final name which contain the value of $blogcacheid.
This fails if the value contains a slash and the debug log shows an error like "FAILED to rename temp wp-cache file to {$dir}{$cache_filename}".

Because of this bug the cache is not working for feeds. It also causes an ever growing number of temporary cache files in the wp-content/cache folder since the temp files won't get deleted when the renaming fails.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in wp-cache-base.php and wp-cache-phase2.php, tracing how a subdirectory multisite value is assigned to $blogcacheid and then included in the final cache filename. Reproduce the issue with a subdirectory multisite install, checking feed caching and the rename failure. Done means cache files can be finalized without accumulating temporary files and feeds are cached.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.