Edit report at http://bugs.php.net/bug.php?id=40163&edit=1
ID: 40163
Comment by: v-ryanbi at microsoft dot com
Reported by: coyle at washpenn dot com
Summary: UNC Path not working
Status: Feedback
Type: Bug
Package: Directory function related
Operating System: Windows 2003
PHP Version: 5.3
Assigned To: pajoye
Block user comment: N
Private report: N
New Comment:
I cannot replicate this bug. Using the following script under IIS
(with and without fastcgi.impersonate), under Apache2.2, and via
CLI, all with recommended INI settings for both 5.3.4RC2 and
5.2.15RC2, I get expected output:
<?php
$share = '\\\\win7-share-af04\\share';
echo 'current user: '; var_dump( get_current_user() );
echo '---TEST-ONE---'."\n";
$targets = array(
'exists' =>'test_folder',
'missing'=>'not_here',
'file'=>'foo.txt',
);
foreach( $targets as $name => $target ) {
echo $name."\n";
$path = $share . DIRECTORY_SEPARATOR . $target;
echo ' path: '; var_dump( $path );
echo ' is_dir: '; var_dump( is_dir( $path ) );
}
echo '---TEST-TWO---'."\n";
$bartxt = fopen( ( $share . DIRECTORY_SEPARATOR . 'bar.txt' ), "w" )
or false;
if( !$bartxt ) {
echo 'failed to open stream';
} else {
fwrite( $bartxt, 'FUBAR '.time() );
fclose( $bartxt );
echo 'wrote file.';
}?>
Example result (IIS with impersonation):
---TEST-ONE---
exists
path: string(43) "\\win7-share-af04\share\test_folder"
is_dir: bool(true)
missing
path: string(40) "\\win7-share-af04\share\not_here"
is_dir: bool(false)
file
path: string(39) "\\win7-share-af04\share\foo.txt"
is_dir: bool(false)
---TEST-TWO---
wrote file.
The file is created properly and is_dir reports accurately in
all scenarios, except that which I don't have permission to see
the share or the share is inaccessible. Have you tried using
procmon to see the request for the file and the filesystem's
response?
Previous Comments:
------------------------------------------------------------------------
[2010-11-26 19:37:30] hjan at libero dot it
Here the SO as showed by phpinfo :
Windows NT W-WEB01 6.1 build 7600 (Unknow Windows version Standard
Edition) i586
it's a Windows 2008 R2 Standard
IIS application pool runs with a domain administrator account. Share
runs on another server, W2003 STD, everyone users has full rights on
both share permission and physical folder permission.
With this test page named testdir.php:
<?php
$path = '\\\\ett2\\tempdb\\';
$f = fopen($path . "somefile.txt", "w") or die ("can't open");
fwrite($f,"AAAAA");
print 'wroted-----';
fclose($f);
if(is_dir($path)) {
print 'directory' . $path . 'exists';
} else {
print 'directory' . $path . ' does not exists';
}
?>
I obtain "can't open" on the web page and this message on the event
log:
The description for Event ID 2 from source PHP-5.3.4RC1 cannot be found.
Either the component that raises this event is not installed on your
local computer or the installation is corrupted. You can install or
repair the component on the local computer.
If the event originated on another computer, the display information had
to be saved with the event.
The following information was included with the event:
php[3852]
PHP Warning: fopen(\\ett2\tempdb\somefile.txt) [<a
href='function.fopen'>function.fopen</a>]: failed to open stream:
Invalid argument in [sitephysicalpath]\testdir.php on line 5
Let me know if you need more information or if i could help with more
test.
Regards,
Gianluca
------------------------------------------------------------------------
[2010-11-26 18:16:15] [email protected]
Not sure what C:\ETT\SITI\moodle\lib\setuplib.php is, but mkdir & co
work just fine here (various windows). Please provide a small script
with an explanation of your configuration (OS version where php runs, OS
where the UNC target is).
------------------------------------------------------------------------
[2010-11-26 16:33:54] hjan at libero dot it
still no luck with 5.3.4RC1
php[4452]
PHP Warning: mkdir() [<a href='function.mkdir'>function.mkdir</a>]:
Invalid argument in C:\ETT\SITI\moodle\lib\setuplib.php on line 167
------------------------------------------------------------------------
[2010-11-26 12:33:34] [email protected]
Please try using 5.3.4RC1.
------------------------------------------------------------------------
[2010-11-26 08:53:06] hjan at libero dot it
PHP 5.3.3, windows 2008 R2, IIS 7.5.
This simple page:
<?php
$path = '\\\\server\\share\\';
$f = fopen($path . "somefile.txt", "w") or die ("can't open");
fwrite($f,"AAAAA");
print 'wroted-----';
fclose($f);
if(is_dir($path)) {
print 'directory' . $path . 'exists';
} else {
print 'directory' . $path . ' does not exists';
}
?>
return me PHP Warning: fopen(\\server\share\somefile.txt)
[function.fopen]: failed to open stream: Invalid argument in
C:\xxx\xxx\moodle\testdir.php on line 4
If I comment the write function I obtain :
directory\\server\share\ does not exists
------------------------------------------------------------------------
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
http://bugs.php.net/bug.php?id=40163
--
Edit this bug report at http://bugs.php.net/bug.php?id=40163&edit=1