|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-09-22 07:52 UTC] philipp at servicemail24 dot de
Description:
------------
PHP 5.3.0 and 5.3.1RC1 has a bug in the is_readable and is_writeable function if you execute a script with normal windows user rights.
The same test script works fine using PHP 5.2.x. Providing admin rights for the user solves the problem but this is not a long term solution for us.
All tested PHP releases are VC6 TS
PHP 5.2.10 -> OK
PHP 5.2.11 -> OK
PHP 5.3.0 -> FAILED
PHP 5.3.1RC1 -> FAILED
Reproduce code:
---------------
$folders = array( '\\\\10.1.1.1\\share',
'\\\\srv\\share',
'd:/temp'
);
foreach($folders as $folder) {
if(@!is_readable($folder)) {
echo('FAILED is_readable: ' . $folder . "\n");
} else {
echo "OK is_readable: " . $folder . "\n";
}
if(@!is_writeable($folder)) {
echo('FAILED is_writeable: ' . $folder . "\n");
} else {
echo "OK is_writeable: " . $folder . "\n";
}
$filename = $folder . '\\test.txt';
if(@!file_put_contents($filename, 'php test')) {
echo('FAILED file_put_contents: ' . $filename . "\n");
} else {
echo "OK file_put_contents: " . $filename . "\n";
}
}
Expected result:
----------------
OK is_readable: \\10.1.1.1\share
OK is_writeable: \\10.1.1.1\share
OK file_put_contents: \\10.1.1.1\share\test.txt
OK is_readable: \\srv\share
OK is_writeable: \\srv\share
OK file_put_contents: \\srv\share\test.txt
OK is_readable: d:/temp
OK is_writeable: d:/temp
OK file_put_contents: d:/temp\test.txt
Actual result:
--------------
FAILED is_readable: \\10.1.1.1\share
FAILED is_writeable: \\10.1.1.1\share
OK file_put_contents: \\10.1.1.1\share\test.txt
FAILED is_readable: \\srv\share
FAILED is_writeable: \\srv\share
OK file_put_contents: \\srv\share\test.txt
OK is_readable: d:/temp
OK is_writeable: d:/temp
OK file_put_contents: d:/temp\test.txt
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 15:00:01 2025 UTC |
I extended my test script with further file sys related functions: if(@!is_dir($folder)) { echo('FAILED is_dir: ' . $folder . "\n"); } else { echo "OK is_dir: " . $folder . "\n"; } if ($dh = @opendir($folder)) { closedir($dh); echo "OK opendir: " . $folder . "\n"; } else { echo('FAILED opendir: ' . $folder . "\n"); } if(@!is_readable($folder)) { echo('FAILED is_readable: ' . $folder . "\n"); } else { echo "OK is_readable: " . $folder . "\n"; } if(@!is_writeable($folder)) { echo('FAILED is_writeable: ' . $folder . "\n"); } else { echo "OK is_writeable: " . $folder . "\n"; } $filename = $folder . '\\test_' . time() . '.txt'; $content = 'php test ' . time(); if(@!file_put_contents($filename, $content)) { echo('FAILED file_put_contents: ' . $filename . "\n"); } else { echo "OK file_put_contents: " . $filename . "\n"; } if(@!is_readable($filename)) { echo('FAILED is_readable: ' . $filename . "\n"); } else { echo "OK is_readable: " . $filename . "\n"; } if(@!is_writeable($filename)) { echo('FAILED is_writeable: ' . $filename . "\n"); } else { echo "OK is_writeable: " . $filename . "\n"; } if(@!file_get_contents($filename) == $content) { echo('FAILED file_get_contents: ' . $filename . "\n"); } else { echo "OK file_get_contents: " . $filename . "\n"; } if(@!unlink($filename)) { echo('FAILED unlink: ' . $filename . "\n"); } else { echo "OK unlink: " . $filename . "\n"; } all functions are fine expect is_readable and is_writeable: 5.3.x result: OK is_dir: \\10.1.1.1\share OK opendir: \\10.1.1.1\share FAILED is_readable: \\10.1.1.1\share FAILED is_writeable: \\10.1.1.1\share OK file_put_contents: \\10.1.1.1\share\test_1253693124.txt FAILED is_readable: \\10.1.1.1\share\test_1253693124.txt FAILED is_writeable: \\10.1.1.1\share\test_1253693124.txt OK file_get_contents: \\10.1.1.1\share\test_1253693124.txt OK unlink: \\10.1.1.1\share\test_1253693124.txt OK is_dir: \\srv\share OK opendir: \\srv\share FAILED is_readable: \\srv\share FAILED is_writeable: \\srv\share OK file_put_contents: \\srv\share\test_1253693124.txt FAILED is_readable: \\srv\share\test_1253693124.txt FAILED is_writeable: \\srv\share\test_1253693124.txt OK file_get_contents: \\srv\share\test_1253693124.txt OK unlink: \\srv\share\test_1253693124.txt 5.2.x result: OK is_dir: \\10.1.1.1\share OK opendir: \\10.1.1.1\share OK is_readable: \\10.1.1.1\share OK is_writeable: \\10.1.1.1\share OK file_put_contents: \\10.1.1.1\share\test_1253693124.txt OK is_readable: \\10.1.1.1\share\test_1253693124.txt OK is_writeable: \\10.1.1.1\share\test_1253693124.txt OK file_get_contents: \\10.1.1.1\share\test_1253693124.txt OK unlink: \\10.1.1.1\share\test_1253693124.txt OK is_dir: \\srv\share OK opendir: \\srv\share OK is_readable: \\srv\share OK is_writeable: \\srv\share OK file_put_contents: \\srv\share\test_1253693124.txt OK is_readable: \\srv\share\test_1253693124.txt OK is_writeable: \\srv\share\test_1253693124.txt OK file_get_contents: \\srv\share\test_1253693124.txt OK unlink: \\srv\share\test_1253693124.txt