ID: 41755 User updated by: mahesh dot vemula at in dot ibm dot com Reported By: mahesh dot vemula at in dot ibm dot com Status: Open Bug Type: Documentation problem Operating System: Linux and Windows -PHP Version: Irrelevant +PHP Version: PHP5 New Comment:
The bug is tested on php5 and php6 Previous Comments: ------------------------------------------------------------------------ [2007-06-21 08:54:02] mahesh dot vemula at in dot ibm dot com Description: ------------ clearstatcache() documentation page: http://in2.php.net/manual/en/function.clearstatcache.php says "if you call file_exists() on a file that doesn't exist, it will return FALSE until you create the file. If you create the file, it will return TRUE even if you then delete the file.". But if we delete the file using unlink(), and then use file_exists() function on the file it returns FALSE, which contradicts with the documentation of clearstatcache(), according to which it should return TRUE even if you delete the file. Samething happening with is_file(), is_dir() functions also. Note: >From unlink() source code, we see that clearstarcache() gets internally called with call to unlink() thus clearing the cache eachtime. Hence the actual output seems to be correct, and the documentation needs to be fixed. For reference: Source code of unlink() : static int php_plain_files_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) { char *p; int ret; zval funcname; zval *retval = NULL; if ((p = strstr(url, "://")) != NULL) { url = p + 3; } if (options & ENFORCE_SAFE_MODE) { if (PG(safe_mode) && !php_checkuid(url, NULL, CHECKUID_CHECK_FILE_AND_DIR)) { return 0; } if (php_check_open_basedir(url TSRMLS_CC)) { return 0; } } ret = VCWD_UNLINK(url); if (ret == -1) { if (options & REPORT_ERRORS) { php_error_docref1(NULL TSRMLS_CC, url, E_WARNING, "%s", strerror(errno)); } 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); } return 1; } Reproduce code: --------------- <?php fclose(fopen("temp.txt", "w")); var_dump(file_exists("temp.txt")); unlink("temp.txt"); var_dump(file_exists("temp.txt")); ?> Expected result: ---------------- bool(true) bool(false) Actual result: -------------- bool(true) bool(false) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41755&edit=1
