#47834 [Csd]: Documentation don't mention, that tempnam() falls back to OS TEMP...
ID: 47834
User updated by: whistl0r+phpbug at googlemail dot com
Reported By: whistl0r+phpbug at googlemail dot com
Status: Closed
Bug Type: Documentation problem
Operating System: win32 only - Windows
PHP Version: 5.2.9
New Comment:
@ fa:
FYI:
It is Windows-dependent, how the folder is called.
<Windows Vista:
%userprofile%\Local Settings\Temp
>=Windows Vista:
%userprofile%\AppData\Local\Temp
And it is also user-dependent:
When you start the web server (e.g. Apache) as user, the path above is
correct. But if you run it as service (LocalService account), then it
points to %windir%\Temp
Previous Comments:
------------------------------------------------------------------------
[2009-04-21 02:54:31] fa@php.net
Verified and fixed in the documentation.
(btw, the directory after the full test directory was c:\Documents and
Settings\user\Local Settings\Temp and not c:\windows\temp)
------------------------------------------------------------------------
[2009-03-31 13:02:19] whistl0r+phpbug at googlemail dot com
Hi,
okay - this is not a bug in PHP. It is a documentation problem.
The english version of the documentation says:
"If the directory does not exist, tempnam() may generate a file in the
system's temporary directory, and return the name of that."
But that's wrong/not correct.
tempnam() will fall back to the system's temporary directory everytime
it cannot write to the specified directory.
So I don't know in what circumstances this function will return
"false".. but anyway... ;)
------------------------------------------------------------------------
[2009-03-30 02:35:05] whistl0r+phpbug at googlemail dot com
Description:
------------
I wanted to check, how tempnam() handles file system limits.
On NTFS, just 65535 files per directory are allowed.
Reproduce code:
---------------
<?php
// Keep script alive
ignore_user_abort(1);
@set_time_limit(0);
$dir = 'C:\Test';
(if (!file_exists($dir))
{
// Create Test directory
mkdir($dir, null, true);
}
$i = 0;
while (tempnam($dir, 'Foobar'))
{
$i++;
}
printf('%u files created', $i);
Expected result:
----------------
The script should stop, because tempnam() should return "false".
The function should return "false", because when 65535 files are in the
specified directory, you reached a limit and aren't able to write to
C:\Test anymore.
Actual result:
--------------
The script will keep running.
After the 65535. file is created in C:\Test, the function will ignore
the specified directory and switch to %temp% (which is usually
C:\Windows\Temp).
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47834&edit=1
Thread (3 messages)