Closed superian closed 9 years ago
Thanks for the detailed report! We are looking into this.
(In the first listing of the wp-content directory, hello.html was the file I was moving up the file system from directory with the compressed CSS until I could access it via the webserver!)
The update that didn't fix this got me doing some more looking at the problem. If I edit the line in wp-content/plugins/quick-cache-pro/submodules/html-compressor/html-compressor/includes/core.php that actually creates the directory (#2305) so that the mkdir bit is
mkdir($dir, 0755, TRUE)
rather than
mkdir($dir, 0775, TRUE)
.. it works. At least under suphp. At least for new installations - old ones will have attempted to create that directory with 0775 permissions and suphp will have gone 'nope, have 0700 instead, you potentially naughty script!'
That just leaves you the simple :) job of testing if 0755 will work for non-suphp setups (I think it will, as whatever owns the script will be doing the writing to that directory - only the quick-cache does, yes?) and coming up with a line that checks if any existing cache directory has those permissions and, if not, chmoding them so it does.
Ah, doing some more experimenting reveals that if you change an existing wp-content/cache directory to be 0755 manually will also work.
mkdir($dir, 0755, TRUE)
Makes sense. Thanks for the follow-ups here! :-)
The HTML compressor works here :) apart from the 'combine CSS from <head> and <body> into fewer files' :(
The file is created...
<!-- Quick Cache HTML Compressor took 0.00719 seconds compiling CSS tag frags in checksum:
1a35ff3dcc73b6c08d0346c2ca31befd
. --> <!-- Quick Cache HTML Compressor took 0.04050 seconds fetching remote resource:http://example.com/wp-content/themes/journalist/style.css
. --> <!-- Quick Cache HTML Compressor took 0.00444 seconds compressing CSS w/ checksum:aa18b43ca244653e8b9cce9de633717a
. --> <!-- Quick Cache HTML Compressor took 0.04791 seconds building parts based on CSS tag frags in checksum:b3147389255003a0160261843d6f4f97
. --> <!-- Quick Cache HTML Compressor took 0.05766 seconds compressing/combining head/body CSS in checksum:505fa5372e9e7f21f19a7689a79d6146
. --> <!-- Quick Cache HTML Compressor took 0.00020 seconds compiling JS tag frags in checksum:2baf6d80a662fbff890ae9cc1b727a78
. --> <!-- Quick Cache HTML Compressor took 0.00034 seconds compressing/combining head JS in checksum:505fa5372e9e7f21f19a7689a79d6146
. --> <!-- Quick Cache HTML Compressor took 0.00001 seconds compiling JS tag frags in checksum:6a80677ab982e087ad3bb25ff1b47044
. --> <!-- Quick Cache HTML Compressor took 0.00021 seconds compressing/combining footer JS in checksum:505fa5372e9e7f21f19a7689a79d6146
. --> <!-- Quick Cache HTML Compressor took 0.00516 seconds compiling JS tag frags in checksum:779b1e8e965b8da661b42608f069d2a5
. --> <!-- Quick Cache HTML Compressor took 0.00726 seconds compressing inline JS in checksum:505fa5372e9e7f21f19a7689a79d6146
. --> <!-- Quick Cache HTML Compressor took 0.00880 seconds compressing HTML w/ checksum:4080dde892a8ede6b2df33aee45fd83c
. --><!-- Quick Cache HTML Compressor took 0.07483 seconds (overall). --> <!-- Quick Cache file path: /cache/quick-cache/cache/http/example.com/index.html --> <!-- Quick Cache file built for (http://example.com/) in 0.48358 seconds, on: Dec 9th, 2014 @ 12:01 pm UTC. --> <!-- This Quick Cache file will auto-expire (and be rebuilt) on: Dec 16th, 2014 @ 12:01 pm UTC (based on your configured expiration time). --> <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- Quick Cache fully functional :-) Cache file served for (http://example.com/) in 0.00128 seconds, on: Dec 9th, 2014 @ 12:02 pm UTC. -->
... and appears in the source:
<link type="text/css" rel="stylesheet" href="http://example.com/wp-content/cache/quick-cache/htmlc/public/example.com/b/3/1/4/7/078e2d57aa83314500e6992d396b6c33-compressor-part.css" media="screen"/>
... and the file exists:
ls -lha example/wp-content/cache/quick-cache/htmlc/public/example-com/b/3/1/4/7/ total 16K drwxr-xr-x 2 ian ian 4.0K Dec 9 11:50 . drwxr-xr-x 3 ian ian 4.0K Dec 9 11:50 .. -rw-r--r-- 1 ian ian 6.1K Dec 9 11:50 078e2d57aa83314500e6992d396b6c33-compressor-part.css
.. but trying to access it results in a 403 'forbidden' message.
This appears to be because, when it is created, the cache directory in wp-content is only accessible by the owner:
ls -lha wp-content/
drwxr-xr-x 10 ian ian 4.0K Dec 9 13:10 . drwxr-xr-x 5 ian ian 4.0K Nov 20 19:14 .. -rw------- 1 ian ian 63K Dec 9 13:03 advanced-cache.php drwx------ 2 ian ian 4.0K May 20 2013 blah drwx------ 3 ian ian 12K Dec 9 13:10 cache -rw-r--r-- 1 ian ian 5 Dec 9 13:07 hello.html -rw-r--r-- 1 ian ian 30 Jun 30 2011 index.php drwxr-xr-x 7 ian ian 4.0K Dec 9 00:11 plugins drwxr-xr-x 4 ian ian 4.0K Sep 4 19:16 themes drwxr-xr-x 2 ian ian 4.0K Dec 9 00:11 upgrade drwxr-xr-x 5 ian ian 4.0K Jan 1 2014 uploads
If it is made accessible to others, it works:
chmod +rx wp-content/cache ls -lha wp-content/cache
drwxr-xr-x 10 ian ian 4.0K Dec 9 13:11 . drwxr-xr-x 5 ian ian 4.0K Nov 20 19:14 .. -rw------- 1 ian ian 63K Dec 9 13:03 advanced-cache.php drwx------ 2 ian ian 4.0K May 20 2013 blah drwxr-xr-x 3 ian ian 12K Dec 9 13:11 cache -rw-r--r-- 1 ian ian 30 Jun 30 2011 index.php drwxr-xr-x 7 ian ian 4.0K Dec 9 00:11 plugins drwxr-xr-x 4 ian ian 4.0K Sep 4 19:16 themes drwxr-xr-x 2 ian ian 4.0K Dec 9 00:11 upgrade drwxr-xr-x 5 ian ian 4.0K Jan 1 2014 uploads
The server is running Debian Wheezy using suphp, so that PHP runs 'as' the user rather than as the webserver. Normally this is fine, but this is a case where the webserver is trying to access a file as the webserver rather than as me...