Bug #52587 [Opn->Fbk]: Clearstatcache() has no effect
| From: | kalle@php.net | Date: | Thu, 12 Aug 2010 02:42:26 +0000 |
| Subject: | Bug #52587 [Opn->Fbk]: Clearstatcache() has no effect | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-153351@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52587&edit=1
ID: 52587
Updated by: kalle@php.net
Reported by: a-krcrai at microsoft dot com
Summary: Clearstatcache() has no effect
-Status: Open
+Status: Feedback
Type: Bug
Package: *Directory/Filesystem functions
Operating System: Windows
PHP Version: 5.3.3
Block user comment: N
New Comment:
Just did a test following the steps from your comment, my results are so
far:
php-trunk, VC9, x86, ZTS/NTS:
bool(true)
bool(true)
bool(true)
bool(true)
php-53, VC9, x86, ZTS/NTS:
bool(true)
bool(true)
bool(true)
bool(true)
I interpreted your steps as:
1) mkdir testdir
2) php -r "file_put_contents('./testdir/testfile', 'PHP on Windows');"
3) Make a php file with the above code inside
4) php bug52587.php
About ACL:
C:\php>setacl -help
SetACL by Helge Klein
Homepage: http://setacl.sourceforge.net
Version: 2.0.3.0
Copyright: Helge Klein
License: GPL
Did you use VC6 or VC9 binaries for your testing?
Previous Comments:
------------------------------------------------------------------------
[2010-08-12 03:20:14] a-krcrai at microsoft dot com
Description:
------------
The results of is_readable() and is_writable() are being cached from the
first result on a filesystem object regardless of whether or not
clearstatcache() is used or in what form (arguments supplied, etc).
This has only been tested on the Windows build of PHP 5.3.3 via the CLI.
It's possible that other functions are being improperly cached as well,
but I haven't had time to test for all of them as of yet.
This does *not*, however, occur in the corresponding Windows builds of
PHP 5.3.2. In that version, no caching took place on either of those
functions at all.
You can easily reproduce this issue if you're running Windows
ACL-related tests on the filesystem in PHP 5.3.3. The sample script I
put together requires the use of SetACL (better cross-Windows version
portability; http://setacl.sourceforge.net) to alter the
file
permissions. Relative to the test script, create a directory named
"testdir", then touch a file within that directory and name it
"testfile". We will be using that file for our test.
This bug occurs on the ZIP-build of PHP 5.3.3 (both nts and zts) run via
CLI without any extensions loaded. It has been successfully reproduced
in Windows XP, Windows 2003, Windows 2003 R2, Windows Vista/7, Windows
2008, and Windows 2008 R2. Has not been tested on Linux.
Test script:
---------------
<?php
exec( "setacl.exe -on testdir -ot file -actn setprot -op
\"dacl:p_nc;sacl:p_nc\" -rec cont_obj" ); //Isolate from any perms
inherited from parent.
exec( "setacl.exe -on testdir -ot file -actn clear -clr DACL -rec
cont_obj" ); //Clear any remaining perms.
exec( "setacl.exe -on testdir -ot file -actn ace -ace
\"n:Everyone;m:grant;p:full\"" ); //Ensures that the parent dir perms
won't affect the results.
exec( "setacl.exe -on testdir/testfile -ot file -actn ace -ace
\"n:Everyone;m:deny;p:full\"" );
var_dump( is_readable( "testdir/testfile" ) );
var_dump( is_writable( "testdir/testfile" ) );
//Tried different variations of clearstatcache() by themselves and
combined. Made no difference either way. Using sleep() after setacl
call made no difference, either.
clearstatcache();
clearstatcache( TRUE, "testdir/testfile" );
exec( "setacl.exe -on testdir/testfile -ot file -actn clear -clr DACL"
);
exec( "setacl.exe -on testdir/testfile -ot file -actn ace -ace
\"n:Everyone;m:grant;p:full\"" );
/* Copy these two var_dumps into a separate PHP file and execute it
immediately after this script.... You'll see the correct bool(true)
results then.
* You can also achieve that result by calling that separate script from
this one via an exec() call (but not as an include). --Kris */
var_dump( is_readable( "testdir/testfile" ) );
var_dump( is_writable( "testdir/testfile" ) );
Expected result:
----------------
bool(false)
bool(false)
bool(true)
bool(true)
Actual result:
--------------
bool(false)
bool(false)
bool(false)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52587&edit=1