Bug #81259 [NEW]: Long execution causes unlink function to give wrong result

From: Date: Wed, 14 Jul 2021 22:45:05 +0000
Subject: Bug #81259 [NEW]: Long execution causes unlink function to give wrong result
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235040@lists.php.net to get a copy of this message
From:             raincomplain at outlook dot com
Operating system: Windows
PHP version:      7.3.29
Package:          Filesystem function related
Bug Type:         Bug
Bug description:Long execution causes unlink function to give wrong result

Description:
------------
As you know on Windows as of PHP 7.3 it is possible to unlink() files
with handles in use (no need to close the handle). To do that it seems
to me that PHP trys to (delay) unlinking until program execution
ends(which is the problem). Unlinking files in the past when a file
handle is open was not possible at all, however as of 7.3 unlink()
returns true even though the file is not deleted yet.

The test script shows that we can do things (creating data2.txt) even
when the program is not correct yet (data.txt has to wait 10 seconds to
be removed).

Test script:
---------------
$fp= fopen('data.txt', 'r');

if (unlink('data.txt')) {
	fopen('data2.txt', 'w');
}
sleep(10);

Expected result:
----------------
.
..
data2.txt

Actual result:
--------------
.
..
data.txt
data2.txt ( for 10 seconds)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=81259&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81259&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81259&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81259&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81259&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81259&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81259&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81259&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81259&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81259&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81259&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81259&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81259&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81259&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81259&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81259&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81259&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81259&r=mysqlcfg


Thread (9 messages)

« previous php.bugs (#235040) next »