Some of the WordPress users who use Redis Object Cache plugin (by Till Krüss) on their websites could experience a “File System: Not Writeable” error from this plugin. This could be caused by the use of DISALLOW_FILE_MODS constant in the WordPress configuration file and therefore some little adjustments must me made.
DISALLOW_FILE_MODS – Better leave it enabled
Many WordPress developers who use version control (e.g. GIT) for their websites certainly do not want any file modifications on a live version of their website. This is both – for security and data integrity, therefore it is logical that they have set this constant to “true” in the WordPress configuration file.
However changing DISALLOW_FILE_MODS constant to FALSE is not a correct solution to this problem. Leave it on if you use it, because there is another fix we can use – specially for Redis.
Why Redis Object Cache do not work with the DISALLOW_FILE_MODS being on anymore?
Starting from the version 2.5.0, the Redis Object Cache plugin now “respects” the use of DISALLOW_FILE_MODS and therefore informs the WordPress admin that the file system is not writeable. While the plugin is still working, after disabling it – it will not allow to enable it again until you solve the issue.
Fix for the problem with DISALLOW_FILE_MODS constant being on
Just place this code in your theme functions.php file or add it as a must-use plugin:
/*B:Allow file modifications for certain operations*/
add_filter( 'file_mod_allowed', 'dwp_allow_file_mod_for_certain_ops', 10, 2 );
function dwp_allow_file_mod_for_certain_ops( $allow_file_mod, $context ) {
if ( in_array($context, ['object_cache_dropin'])) {
return true;
} else {
return $allow_file_mod;
}
}
/*E:Allow file modifications for certain operations*/
And this should solve the issue with file system check.