From: Jani Taskinen Date: Wed, 31 Oct 2007 13:22:18 +0000 (+0000) Subject: - Fixed bug #43137 (rmdir() and rename() do not clear statcache) X-Git-Tag: RELEASE_2_0_0a1~1518 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb1a26c8b27756154dc3bfc3525b3a751e6f8ee2;p=php - Fixed bug #43137 (rmdir() and rename() do not clear statcache) --- diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index 60a3a53ccb..beb70ae1f7 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -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) diff --git a/ext/standard/php_filestat.h b/ext/standard/php_filestat.h index 0fb9202b8c..d426cd46f7 100644 --- a/ext/standard/php_filestat.h +++ b/ext/standard/php_filestat.h @@ -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); diff --git a/ext/standard/tests/file/005_basic.phpt b/ext/standard/tests/file/005_basic.phpt index e7f9181c59..6673284e35 100644 --- a/ext/standard/tests/file/005_basic.phpt +++ b/ext/standard/tests/file/005_basic.phpt @@ -1,5 +1,5 @@ --TEST-- -Test fileatime(), filemtime(), filectime() & touch() functions: basic functionality +Test fileatime(), filemtime(), filectime() & touch() functions : basic functionality --FILE-- +--EXPECT-- +bool(true) +bool(false) +bool(true) +bool(false) diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 6611d50137..bd2735375b 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -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 #include #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