]> granicus.if.org Git - php/commitdiff
- Fixed bug #43137 (rmdir() and rename() do not clear statcache)
authorJani Taskinen <jani@php.net>
Wed, 31 Oct 2007 13:22:18 +0000 (13:22 +0000)
committerJani Taskinen <jani@php.net>
Wed, 31 Oct 2007 13:22:18 +0000 (13:22 +0000)
ext/standard/filestat.c
ext/standard/php_filestat.h
ext/standard/tests/file/005_basic.phpt
ext/standard/tests/file/005_error.phpt
ext/standard/tests/file/bug43137.phpt [new file with mode: 0644]
main/streams/plain_wrapper.c

index 60a3a53ccb15cf61285da4a4a617aa40be812464..beb70ae1f705156d82a4ca8c8bc8d8e725570ebb 100644 (file)
@@ -751,14 +751,10 @@ PHP_FUNCTION(touch)
 /* }}} */
 #endif
 
-/* {{{ proto void clearstatcache(void) U
-   Clear file stat cache */
-PHP_FUNCTION(clearstatcache)
+/* {{{ php_clear_stat_cache()
+*/
+PHPAPI void php_clear_stat_cache(TSRMLS_D)
 {
-       if (ZEND_NUM_ARGS()) {
-               WRONG_PARAM_COUNT;
-       }
-
        if (BG(CurrentStatFile)) {
                efree(BG(CurrentStatFile));
                BG(CurrentStatFile) = NULL;
@@ -771,6 +767,17 @@ PHP_FUNCTION(clearstatcache)
 }
 /* }}} */
 
+/* {{{ proto void clearstatcache(void)
+   Clear file stat cache */
+PHP_FUNCTION(clearstatcache)
+{
+       if (ZEND_NUM_ARGS()) {
+               WRONG_PARAM_COUNT;
+       }
+       php_clear_stat_cache(TSRMLS_C);
+}
+/* }}} */
+
 #define IS_LINK_OPERATION(__t) ((__t) == FS_TYPE || (__t) == FS_IS_LINK || (__t) == FS_LSTAT)
 #define IS_EXISTS_CHECK(__t) ((__t) == FS_EXISTS  || (__t) == FS_IS_W || (__t) == FS_IS_R || (__t) == FS_IS_X || (__t) == FS_IS_FILE || (__t) == FS_IS_DIR || (__t) == FS_IS_LINK)
 #define IS_ABLE_CHECK(__t) ((__t) == FS_IS_R || (__t) == FS_IS_W || (__t) == FS_IS_X)
index 0fb9202b8c862b9c76be33e1670ee90a1403c2a7..d426cd46f715803a0568c0d427d1b63a1948db81 100644 (file)
@@ -87,6 +87,7 @@ typedef unsigned int php_stat_len;
 typedef int php_stat_len;
 #endif
 
+PHPAPI void php_clear_stat_cache(TSRMLS_D);
 PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int type, zval *return_value TSRMLS_DC);
 PHPAPI void php_u_stat(zend_uchar filename_type, const zstr filename, php_stat_len filename_length, int type, php_stream_context *context, zval *return_value TSRMLS_DC);
 
index e7f9181c59f74a0a8f2f8824d909a83de1d10c2d..6673284e35f25c4a8472ae27de204bbedd9efcc1 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Test fileatime(), filemtime(), filectime() & touch() functions: basic functionality
+Test fileatime(), filemtime(), filectime() & touch() functions : basic functionality
 --FILE--
 <?php
 /* 
index 5166a5f5357f6795bf4736a3e9da6154356f04df..d41d957cb2304e41939b38efe633231d67732e4d 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Test fileatime(), filemtime(), filectime() & touch() functions: error conditions 
+Test fileatime(), filemtime(), filectime() & touch() functions : error conditions 
 --FILE--
 <?php
 /*
diff --git a/ext/standard/tests/file/bug43137.phpt b/ext/standard/tests/file/bug43137.phpt
new file mode 100644 (file)
index 0000000..8125445
--- /dev/null
@@ -0,0 +1,20 @@
+--TEST--
+Bug #43137 (rmdir() and rename() do not clear statcache)
+--FILE--
+<?php
+       $toname = "TO_" . md5(microtime());
+       $dirname = "FROM_" . md5(microtime());
+
+       mkdir($dirname);
+       var_dump(is_dir($dirname)); // Expected: true
+       rename($dirname, $toname);
+       var_dump(is_dir($dirname)); // Expected: false
+       var_dump(is_dir($toname)); // Expected: true
+       rmdir($toname);
+       var_dump(is_dir($toname)); // Expected: false
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
index 6611d501373796450438c936401762f68d8ef011..bd2735375b59c808c7408bec70c94f51e52d0129 100644 (file)
@@ -24,6 +24,7 @@
 #include "php_open_temporary_file.h"
 #include "ext/standard/file.h"
 #include "ext/standard/flock_compat.h"
+#include "ext/standard/php_filestat.h"
 #include <stddef.h>
 #include <fcntl.h>
 #if HAVE_SYS_WAIT_H
@@ -1025,13 +1026,10 @@ static int php_plain_files_unlink(php_stream_wrapper *wrapper, char *url, int op
                }
                return 0;
        }
+
        /* Clear stat cache */
-       ZVAL_ASCII_STRINGL(&funcname, "clearstatcache", sizeof("clearstatcache")-1, 1);
-       call_user_function_ex(CG(function_table), NULL, &funcname, &retval, 0, NULL, 0, NULL TSRMLS_CC);
-       zval_dtor(&funcname);
-       if (retval) {
-               zval_ptr_dtor(&retval);
-       }
+       php_clear_stat_cache(TSRMLS_C);
+
        return 1;
 }
 
@@ -1096,6 +1094,9 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c
         return 0;
        }
 
+       /* Clear stat cache */
+       php_clear_stat_cache(TSRMLS_C);
+
        return 1;
 }
 
@@ -1203,6 +1204,9 @@ static int php_plain_files_rmdir(php_stream_wrapper *wrapper, char *url, int opt
                return 0;
        }
 
+       /* Clear stat cache */
+       php_clear_stat_cache(TSRMLS_C);
+
        return 1;
 }
 
@@ -1359,9 +1363,6 @@ stream_skip:
 }
 /* }}} */
 
-
-
-
 /*
  * Local variables:
  * tab-width: 4