Bug #64410 [Com]: sys_get_temp_dir() returns incorrect path

From: Date: Mon, 23 May 2016 14:06:23 +0000
Subject: Bug #64410 [Com]: sys_get_temp_dir() returns incorrect path
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201241@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64410&edit=1

 ID:                 64410
 Comment by:         biloo1 at caramail dot com
 Reported by:        md dot xytop at gmail dot com
 Summary:            sys_get_temp_dir() returns incorrect path
 Status:             Wont fix
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   Windows 8
 PHP Version:        5.3.22
 Block user comment: N
 Private report:     N

 New Comment:

I find the problem for me: Apache "don't show" the TEMP variable to PHP.

I add this in httpd.conf : PassEnv TEMP

Then the problem disappears.

Hope that helps !


Previous Comments:
------------------------------------------------------------------------
[2016-05-23 13:00:49] biloo1 at caramail dot com

In same context, the tempnam function reproduce this bug :

echo tempnam("", "");

returns: 'C:\Windows\A760.tmp'

------------------------------------------------------------------------
[2016-05-23 12:46:32] biloo1 at caramail dot com

PHP 5.3.10 via CGI (Action application/x-httpd-php "/php/php-cgi.exe")
Apache 2.2.29
Windows 7 Pro SP1

sys_get_temp_dir() returns path 'C:\Windows'

My windows variables are set to '%SystemRoot%\TEMP' and
'%USERPROFILE%\AppData\Local\Temp' BUT NOT TO 'C:\Windows' (%SystemRoot%)

------------------------------------------------------------------------
[2013-07-09 09:59:15] ab@php.net

Ok, just tried it again with IIS+fastcgi+win8, it gives c:\windows\temp .

The windows implementation uses this API function to determine the temporary dir
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364992(v=vs.85).aspx

According to that docs, c:\windows is the very last fallback when none of TMP, 
TEMP, USERPROFILE has worked. Conclusion - this is neither PHP nor Win API issue, 
but an environment one. For 5.4 one of those environment variables has to be set, 
for 5.5+ additionally sys_temp_dir is usable.

------------------------------------------------------------------------
[2013-07-08 18:57:13] czarek dot tomczak at gmail dot com

In the latest PHP 5.5.0 the temp directory on Windows 8 is "C:\Windows",
just confirmed by one of the users.

------------------------------------------------------------------------
[2013-07-06 13:55:26] czarek dot tomczak at gmail dot com

I can confirm this issue, using PHP 5.4.10 via CGI. Recently two 
users of the PHP Desktop project have reported problems with the 
temp directory on Windows 8:

https://code.google.com/p/phpdesktop/issues/detail?id=23
https://code.google.com/p/phpdesktop/issues/detail?id=39

In both cases the temp directory returned by sys_get_temp_dir() 
is "C:\Windows".

Seems like the php version doesn't matter, it happens on php 5.3,
5.4, 5.5.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=64410


--
Edit this bug report at https://bugs.php.net/bug.php?id=64410&edit=1


Thread (9 messages)

« previous php.bugs (#201241) next »