lscache_wp
lscache_wp copied to clipboard
wp-config.php write error
Please remove the
wp-config.php operation failed when changing
WP_CACHEconst: File public_html/wp-config.php is not writable.
error message if the WP_CACHE variable is already defined, something like this:
if(defined('WP_CACHE') && WP_CACHE){ return true; }
In the end, it looks like Litespeed cache plugin 3+ version does not use the advanced-cache.php file and here is the description for WP_CACHE varaible.
The WP_CACHE setting, if true, includes the wp-content/advanced-cache.php script, when executing wp-settings.php.
Thanks for reminding. I was planning to have a look on WP_CACHE const, but met some other issues and forgot about it. Will check.
In wp-settings.php, WP_CACHE also is used by object cache. So it needs to be defined.
// Run wp_cache_postload() if object cache is enabled and the function exists.
if ( WP_CACHE && function_exists( 'wp_cache_postload' ) ) {
wp_cache_postload();
}
If your concern is about advanced-cache only, how about set enable_loading_advanced_cache_dropin filter to false?
Make it simple and just check if the WP_CACHE variable is defined and it's true before throwing a write permissions error.
If the user or another plugin defined the WP_CACHE variable other than in the wp-config.php file, it's their mistake because they do not follow the WordPress docs.
Not sure if I followed your idea correctly or not. But in https://github.com/litespeedtech/lscache_wp/blob/master/src/activation.cls.php#L328 I checked if it exists or not. If true, won't modify that file.
Looks fine.
The error message still exists, maybe we need to check the code?
In your wp-config.php, is that WP_CACHE const defined already? Can you paste the context?
Can you tell which action caused that warning? Update settings? If so, what is the Cache enable status setting?
The define('WP_CACHE', true); varaible is always defined in wp-config.php file. The error message appears after activating the Litespeed cache plugin.
http://prntscr.com/txvac3
Is the line define('WP_CACHE', true); added in your activation process dynamically? Or prior to that process?
If you define it in activation, means wp-config.php is already included by WP w/o that const. In this case, you will need to temp define that const around the code you operate wp-config.php.
The WP_CACHE variable is defined even before installing WordPress but the wp-config.php file is not writeable by the PHP user.
To reproduce the issue, define the variable, change the wp-config.php file permission and try to activate the Litespeed cache plugin.
We tried in different environments but can't reproduce it. Does that only happen on certain VPS? E.g. Closter?
Was there ever any solution? I'm on Closte hosting and getting the same error message when activating litespeed.
Hi @hungryjos Since we could not reproduce this in the past, could you please open a ticket here? https://store.litespeedtech.com/store/submitticket.php We may need to work with you more closely to investigate into this, and we'll start from there. Btw, please specify assigning your ticket to Abe in the ticket so our team members will forward it to me.
When I was using litespeed, I also encountered the problem of not being able to write wp-config .php files, and my first thought was probably that the permissions were not enough, and after some research, I finally solved the problem by modifying the owner of the wp-config .php to nginx
Thanks for the sharing @huaizhu1
Did you figure out why you had to change the owner to nginx?