php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25094 rename() function caches a source file info
Submitted: 2003-08-14 06:53 UTC Modified: 2003-08-15 07:08 UTC
From: naumovic at beotel dot yu Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.2 OS: Win 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: naumovic at beotel dot yu
New email:
PHP Version: OS:

 

 [2003-08-14 06:53 UTC] naumovic at beotel dot yu
Description:
------------
When i try to rename a file, then to check if the source file exists, file_exists() returns me true. A conclusion is that a source file info is cached when using rename() function. 
My solution was to call clearcache() between rename() and file_exists(). I'm not sure if anyone else will consider it as a bug, but i suppose it's not a desired behavior.
In the Reproduce code i put casting into integer just for the sake of displaying 0 if the file doesn't exist instead of an empty string.

Reproduce code:
---------------
rename('oldFile.txt', 'newFile.txt');
echo((int) file_exists('oldFile.txt');

Expected result:
----------------
1

Actual result:
--------------
0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-15 07:08 UTC] sniper@php.net
This comment was lost due to database corruption: 

"The code works properly, after you've renamed the file 'oldFile.txt' no longer exists, which is why file_exists() returns 0/FALSE."

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Sep 16 13:00:01 2025 UTC