• Resolved davros1973b

    (@davros1973b)


    Sorry – I’m probably being thick. Spent hours looking at this, read many answers to similar issues, but rusty on php and I can’t understand yet what’s going wrong. Might be mis-interpreting what I’m seeing, making big assumptions / false-premise etc. OR: maybe what I want to do can’t be done?

    WP 3.92 running on my PC, Windows 8.1, IIS 8.5, PHP 5.5.15

    Essentially: plug-in updates:
    “Download failed. Destination directory for file streaming does not exist or is not writeable.”

    I’ve tried many experiments with ACL settings, php settings and windows temp directory settings etc. but simply here: testing:
    F:\TEST ACL’s set to everyone full control, plus to be absolutely certain, the php apppool set to full control
    ALSO: allowed same privileges for the entire WP directory and sub-directories (for testing).

    If I do in wp_config:
    define(‘WP_TEMP_DIR’, ‘F:\TEST/’); then I still get the error.

    If I do in wp_config:
    define(‘WP_TEMP_DIR’, ABSPATH . ‘wp-content/’); then it works

    I wanted to use a directory outside of the WP path. Is it simply not doable?

    To check if the issue seemed to be with PHP, I inserted the below in header.php in the responsive theme:

    <?php echo 'get_temp_dir() = ' . get_temp_dir() . '    ';
                $filename='F:\TEST\test.txt';
                If(!file_exists($filename)){
                    echo "file_exists function could not find " . 'F:\TEST\test.txt';
                }
                else{
                    echo "file_exists function FOUND " . 'F:\TEST\test.txt    ';
                }
    
                echo 'is_writable(F:\TEST\test.txt) = ... ' . is_writable('F:\TEST\test.txt');
                $myfile = fopen('F:\TEST\test.txt', "w") or die("Unable to open file!");
                $txt = "John Doe\n";
                fwrite($myfile, $txt);
                $txt = "Jane Doe\n";
                fwrite($myfile, $txt);
                fclose($myfile);
                ?>

    In my header I got:
    1st run: get_temp_dir() = F:\TEST/ file_exists function could not find F:\TEST\test.txtis_writable(F:\TEST\test.txt) = …

    Refresh: get_temp_dir() = F:\TEST/ file_exists function FOUND F:\TEST\test.txt is_writable(F:\TEST\test.txt) = … 1

    And I opened F:\TEST\test.txt in Windows Explorer and the writes had been made.

    My interpretation: php can write to the directory I specify. WP_TEMP_DIR seems to tell WP the folder to use for download/unpacking etc. and is happy with the path form if the folder is wp_content or a subdirectory but not if something else. So – my interpretation … WP is doing something different? I don’t understand.

    nb: not using open base dir or doc root stuff. I do use fgi impersonate … & normally basic authentication (windows user though planning on using LDAP eventually) (and set relevant ACL too) – but tried it without & anonymous … same thing.

    Is there a quick answer? Should it work? I have no professional experience in this stuff … my day job is just a grade 4 local authority administrator dealing with market traders … this is just a means to an end. I wasn’t expecting this kind of problem. Just a pointer would be very welcome! Or, sigh, do I have to go through all the code line by line to understand it? 🙁 I have many competing priorities from other complex non-php projects / demands on my time and didn’t want to have to do that just for this little problem. 🙁 I’m very shy (diagnosed autism) and asking is actually very difficult for me … I feel very embarrassed and awkward. It’s not a last resort … but getting there. Ta. (Hoping it’s dead-simple and me being thick!).

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter davros1973b

    (@davros1973b)

    Fixed it.

    The solution was to make a subdirectory for my temp directory. I haven’t tested with the parent directory having different permissions … so don’t know if that would affect anything … but this worked for me:

    define(‘WP_TEMP_DIR’, ‘F:\TEST\tmp/’);

    (So that’s with full permissions … my next job is to refactor everything security-wise – planning to make a plugin to use setACL.exe triggered via Windows task scheduler to store elevated privileges ).

    nb: below lines had no impact for me.
    define(‘FS_METHOD’,’direct’);
    putenv(‘TMPDIR=F:\TEST\tmp/’);

    I’ve got a headache now. Why isn’t anything simple!!! I wish something somewhere specified these requirements but if there is, I’ve overlooked it. 🙁

    Thread Starter davros1973b

    (@davros1973b)

    nb: subdirectory doesn’t have to be called “tmp”. I changed it to “temp”.

    nb: forgot to say … I only use this site on https binding. I give a message on the “main site” and just use a subdirectory/iis application for the wp site. I store wp-config.php outside the www directory altogether … just using a stub thingy with a require once in the directory above the wp directory … but define a custom constant in wp-load that I check for in my wp-config “stub” to give a dummy php error output giving false paths to my actual wp-config.php (my php display error is actually off) … just to throw casual hackers off the scent a bit. (The basic authentication is just on the wp sub directory).

    nb: forgot … my IIS basic settings for site set for pass through authentication for user (and I use basic authentication on this site – just a private site for documenting/organising another shared project) so at the moment I’ve just set ACL for both the isolated apppool (not sure if necessary) and one authenticated standard windows user that I currently use for basic authentication pending LDAP / role based authentication)

    Updates seem to work fine with parent directory TEST just having “List folder contents” set. And the “temp” folder set with “modify” level access.

    My wp-contents folder also set with “modify” level access for the php user – for convenience for now ’til I make a convenient way to raise the access permissions automatically when needed in a secure way in windows (not a straightforward chmod exercise with ftp settings etc. as I understand it)

    My conclusive thoughts to it all is that wp must require some parent traversal for the temp directory setting for some reason though doesn’t seem to require read/execute but just list folder contents (in windows terms – not clear on chmod equivalents – individual execute? I don’t use Linux much – very little time and I like being able to help ordinary people and believe in the ideology that software should be transparent e.g. a person shouldn’t have to be an expert mechanic and modify their car engine before they can drive the car just to get from A to B … I like Ubuntu but even there just installing flash e.g. for BBC Iplayer isn’t in my opinion straight forward for a casual user!)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘php can write to tmp dir, but not wp for plugin update?’ is closed to new replies.