WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
file and directory tests failed (6 posts)

  1. drozd
    Member
    Posted 1 year ago #

    Hi,

    I am using W3 Total Cache with Amazon cloudfront.

    After set up w3 Total Cache, it gives a mistake: "File and directory creation tests failed

    Could not create file in /var/www/vhosts/christine.ee/httpdocs/wp-content/cache/test_dir using file_put_contents.
    Could not create file in /var/www/vhosts/christine.ee/httpdocs/wp-content/cache/test_dir using fputs."

    Could you please tell me what to do to make it work properly?

  2. jingle0
    Member
    Posted 1 year ago #

    I am having this problem as well. Did you figure this out?

  3. dikla.php
    Member
    Posted 1 year ago #

    I am having this problem as well with W3 Total Cache.

  4. Alok Sharma
    Member
    Posted 1 year ago #

    I am too having this problem and unable to fix it either.

  5. jaap
    Member
    Posted 1 year ago #

    We have had the same problem. The problem exists because we use an NFS share for some of our websites. The code of the W3 Total Cache plugin attempts to do an flock on the filesystem, but in our case, no lock daemon exists. This causes the code to hang and a non-responsive dashboard is the result.

    A fix is to remove the flock's from the code. In wp-content/plugins/w3-total-cache/lib/W3/Setup.php, starting at line 455, change

    private function _test_create_file_fputs($test_file) {
            $fp = @fopen($test_file, 'w');
    
            if (!$fp)
                return false;
            if (@flock($fp, LOCK_EX)) {
                @fputs($fp, $test_file);
                @fclose($fp);
                @flock($fp, LOCK_UN);
                @unlink($test_file);
                return true;
            } else {
                return false;
            }
        }

    to

    private function _test_create_file_fputs($test_file) {
            $fp = @fopen($test_file, 'w');
    
            if (!$fp)
                return false;
                @fputs($fp, $test_file);
                @fclose($fp);
                @unlink($test_file);
                return true;
        }

    which essentially is the same as

    private function _test_create_file_fputs($test_file) {
            $fp = @fopen($test_file, 'w');
    
            if (!$fp)
                return false;
                return true;
        }

    This removes the flock and all is good again.

    Using WP 3.5.1 and W3 Total Cache 0.9.2.8.

  6. mmcn
    Member
    Posted 1 year ago #

    i ve done the samething as it shown above but i doesnt work for my site.

    have any other idea to solve the problem?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic