tlovett1 / simple-cache

A simple caching plugin for WordPress.
https://wordpress.org/plugins/simple-cache/
129 stars 33 forks source link

Permissions issue #17

Open banago opened 8 years ago

banago commented 8 years ago

Hey @tlovett1

I'm having trouble with having the plugin work. It shows that wrong permission issue for the fopen() function. I've set all the right users and permission, 775 but it still won't work. I had to drop the plugin for now and install WP Super Cache which works fine under these permissions.

Could you have a look at this?

banago commented 8 years ago

I don't think it's smart to cache this value:

$cant_write = get_option( 'sc_cant_write', false );

That's seems to be the reason why I could not use the plugin even when I updated the permissions. What do you suggest here?

tlovett1 commented 8 years ago

Who is your host?

banago commented 8 years ago

This happens on Amazon VPS (ec2) running Ubuntu 16.04 and php7.

leewillis77 commented 7 years ago

It may not be the same as the original poster's issue, however I'm just going to note my own experience here as it may well be relevant.

I was receiving the following message:

Simple Cache can't create or modify needed files on your system. Specifically, Simple Cache needs to write to wp-config.php and /wp-content using PHP's fopen() function. Contact your host."

I thought this was pretty strange as the plugin should have been able to make the needed changes with the permissions as was. However, I temporarily chmod'd wp-config.php and wp-content dir to 777, and still received the error.

It turns out that simple cache runs a number of checks beyond just "can I write a file". Specifically, one of the checks it performs is that the owner of the created file matches the owner of the plugin files. I'm not sure why it would check that, however on my environment that was causing the failure since the plugin files are owned by a deployment user, not the web server.

So, even though the plugin was perfectly capable of creating / modifying the files it needed it was failing the check because the created files weren't owned by the same user as the plugin files.

The offending checks are here: https://github.com/tlovett1/simple-cache/blob/master/inc/class-sc-config.php#L149

Can these be removed?