lscache_wp icon indicating copy to clipboard operation
lscache_wp copied to clipboard

wp-config.php write error

Open closte opened this issue 5 years ago • 15 comments

Please remove the

wp-config.php operation failed when changing WP_CACHE const: 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.

closte avatar May 06 '20 15:05 closte

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.

hi-hai avatar May 06 '20 15:05 hi-hai

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?

hi-hai avatar May 06 '20 17:05 hi-hai

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.

closte avatar May 06 '20 18:05 closte

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.

hi-hai avatar May 06 '20 18:05 hi-hai

Looks fine.

closte avatar May 06 '20 18:05 closte

The error message still exists, maybe we need to check the code?

closte avatar Aug 11 '20 11:08 closte

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?

hi-hai avatar Aug 11 '20 12:08 hi-hai

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

closte avatar Aug 11 '20 15:08 closte

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.

hi-hai avatar Aug 11 '20 17:08 hi-hai

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.

closte avatar Aug 12 '20 11:08 closte

We tried in different environments but can't reproduce it. Does that only happen on certain VPS? E.g. Closter?

hi-hai avatar Aug 12 '20 15:08 hi-hai

Was there ever any solution? I'm on Closte hosting and getting the same error message when activating litespeed.

hungryjos avatar Jan 31 '22 10:01 hungryjos

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.

usabe avatar Jan 31 '22 16:01 usabe

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

huaizhu1 avatar Apr 27 '22 07:04 huaizhu1

Thanks for the sharing @huaizhu1

Did you figure out why you had to change the owner to nginx?

usabe avatar Apr 27 '22 15:04 usabe