From: Jani Taskinen Date: Wed, 31 Oct 2007 13:23:07 +0000 (+0000) Subject: MFH: - Fixed Bug #43137 (rmdir() and rename() do not clear statcache) X-Git-Tag: php-5.2.5RC2~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bdbcc4b6d3372a5bb15fbafda831c325b859bc4e;p=php MFH: - Fixed Bug #43137 (rmdir() and rename() do not clear statcache) --- diff --git a/NEWS b/NEWS index 0fc67a7707..845efea722 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ PHP NEWS ?? ??? 2007, PHP 5.2.5RC2 - Added ability to control memory consumption between request using ZEND_MM_COMPACT environment variable. (Dmitry) +- Fixed bug #43137 (rmdir() and rename() do not clear statcache). (Jani) 18 Oct 2007, PHP 5.2.5RC1 - Upgraded PCRE to version 7.3 (Nuno) diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 00dbd3f641..f6fa85ef59 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -46,6 +46,9 @@ #include #include +/* Common */ +#include + #define DEFAULT_KEY_LENGTH 512 #define MIN_KEY_LENGTH 384 diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index cfc364d2f4..3182237527 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -698,14 +698,10 @@ PHP_FUNCTION(touch) /* }}} */ #endif -/* {{{ proto void clearstatcache(void) - 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; @@ -718,6 +714,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 b0aae0a76c..f819b2bcbf 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); /* Switches for various filestat functions: */ diff --git a/ext/standard/tests/file/005_basic.phpt b/ext/standard/tests/file/005_basic.phpt index 44a49d8cd0..5ed1118902 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 74c1841950..438ba3aabd 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 @@ -1032,12 +1033,10 @@ static int php_plain_files_unlink(php_stream_wrapper *wrapper, char *url, int op } return 0; } + /* Clear stat cache */ - ZVAL_STRINGL(&funcname, "clearstatcache", sizeof("clearstatcache")-1, 0); - call_user_function_ex(CG(function_table), NULL, &funcname, &retval, 0, NULL, 0, NULL TSRMLS_CC); - if (retval) { - zval_ptr_dtor(&retval); - } + php_clear_stat_cache(TSRMLS_C); + return 1; } @@ -1107,6 +1106,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; } @@ -1151,7 +1153,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod } else { /* find a top level directory we need to create */ - while ( (p = strrchr(buf + offset, DEFAULT_SLASH)) || ( offset !=1 && (p = strrchr(buf, DEFAULT_SLASH))) ) { + while ( (p = strrchr(buf + offset, DEFAULT_SLASH)) || (offset != 1 && (p = strrchr(buf, DEFAULT_SLASH))) ) { int n = 0; *p = '\0'; @@ -1218,6 +1220,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; } @@ -1412,9 +1417,6 @@ stream_skip: } /* }}} */ - - - /* * Local variables: * tab-width: 4