jetpack
jetpack copied to clipboard
Flushing cache should not require `wp-cache-config.php` being writable
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)
In the meantime, I found a workaround for this. Adding this line to wp-config.php
will prevent the button from being disabled, and clicking it will successfully flush the cache:
define( 'SUBMITDISABLED', false ); // work around https://github.com/Automattic/jetpack/issues/25542
I have made my wp-cache-config.php readonly since it is being broken a lot of times and when I tried to updated a comment, I gotta the following msg:
Error: file /public_html/wp-content/wp-cache-config.php is not writable.
I was wondering why it has to be written when a comment is updated, is there any reason for that?
@iandunn I'm not sure that doing that is the best solution. The problem here is that all forms are treated uniformly, including those that do not modify the configuration file in any way; making the submit button enabled for all pages of the plugin might potentially break things since people could forcefully attempt to modify the config file and it would silently(ish) fail.
The real fix here would be to make sure that the submit button isn't disabled on the Contents page. The odd thing here, to me, is that the Plugins and Preload pages both work correctly with a read-only config so somewhere it seems like Cache is accidentally being set to SUBMITDISABLED if the config isn't readable.
Will this particular issue be fixed by Automattic/wp-super-cache#563?