wp-ffpc
wp-ffpc copied to clipboard
deploy_advanced_cache() fails to save because Wordpress Filesystem API is not used
deploy_advanced_cache() fails to save on my Wordpress server setup because the Wordpress Filesystem API is not used. https://codex.wordpress.org/Filesystem_API
Specifically, in my scenario the user under which the apache webservice runs does not have permissions to write to /wp-content and, of course, the needed advanced-cache.php file.
This scenario setup is a hardened setup. Wordpress fully supports this and abstracts away the problem by using the Wordpress Filesystem APIs. On my servers, I have configured Wordpress to allow a different user "wpadmin" to write to files/directories. This wpadmin user can do so using SSH2 and this is transparent after the initial wordpress config. https://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants
I see in your code you often use file_put_contents(). In many of those location, it should be replaced with the Wordpress Filesystem API. This will then allow transparent file saves for php/config files in all situations (non-hardened, hardened, ftp, ssh2, etc.).