Automattic / Automattic/wp-super-cache

Flushing cache should not require `wp-cache-config.php` being writable

Open
#929 4 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

I keep `wp-cache-config.php` read-only for PHP's user, because I want all changes to configuration files to be properly tracked in version control, which is a best practice.

Doing that prevents admins from clearing the cache, though. It doesn't seem like there's any reason why Super Cache would need to write to `wp-cache-config.php` in order to clear the cache.

If the config file isn't writable, then `wp_cache_manager_error_checks()` defines `SUBMITDISABLED` so that the `Delete Cache` button is disabled.

But calling the prune function manually works even with the file unwritable:

```
> wp shell --url=https://foo.example.org
wp> require_once( 'wp-content/plugins/wp-super-cache/wp-cache-phase1.php' )
wp> prune_super_cache( 'wp-content/cache/supercache/foo.example.org', true )
=> int(50)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Read wp_cache_manager_error_checks() first, then compare its SUBMITDISABLED path with the manually demonstrated prune_super_cache() call in wp-cache-phase1.php. Done means an unwritable wp-cache-config.php no longer disables Delete Cache while cache pruning still works.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.