From: mahesh dot vemula at in dot ibm dot com Operating system: Linux and Windows PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: clearstatcache() documentation needs to be updated
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 bug report at http://bugs.php.net/?id=41755&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41755&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41755&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41755&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41755&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41755&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41755&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41755&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41755&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41755&r=support Expected behavior: http://bugs.php.net/fix.php?id=41755&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41755&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41755&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41755&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41755&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41755&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41755&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41755&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41755&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41755&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41755&r=mysqlcfg
