php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76947 file_put_contents() blocks the directory of the file (__DIR__)
Submitted: 2018-09-29 10:39 UTC Modified: 2018-09-30 18:19 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:3 (100.0%)
From: bugzilla77 at gmail dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 7.3.0RC2 OS: Windows 10 Pro 1803
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: bugzilla77 at gmail dot com
New email:
PHP Version: OS:

 

 [2018-09-29 10:39 UTC] bugzilla77 at gmail dot com
Description:
------------
file_put_contents() blocks the directory of the file (__DIR__)

This is PHP 7.3 beta and RC regression.
There is no problem with PHP 7.2.x.

1. Create file using file_put_contents()
2. Now, you can NOT remove the directory of the file (__DIR__).

It happens only when FastCGI using.

Test script:
---------------
<?php
// Windows 10 Pro 1803
// PHP 7.3RC2 NTS 64 bit
// Only FastCGI problem
// BUG: file_put_contents() blocks the directory of the file (__DIR__)

 file_put_contents('temp.txt','');

// Now, try to remove manualy the directory of the file (__DIR__ with content)
// PHP 7.3.RC2 - you can not!
// PHP 7.2.10 - you can
?>

Expected result:
----------------
I can remove the directory of the file (__DIR__).

Actual result:
--------------
I can NOT remove the directory of the file (__DIR__).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-09-29 18:01 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2018-09-29 18:01 UTC] requinix@php.net
You say regression. Was this reported as a bug and fixed in the past?

Are you sure the problem is not that you have PHP running as a different user, and the created file has ownership/permissions set that you cannot remove it and thus cannot delete its parent directory?
 [2018-09-30 17:58 UTC] bugzilla77 at gmail dot com
-Status: Feedback +Status: Open
 [2018-09-30 17:58 UTC] bugzilla77 at gmail dot com
Full instruction
----------------

 1. Install Windows 10 1803 Pro
 2. Disable UAC, firewall and restart
 3. Download http://nethium.idsl.pl/dir_block.zip
 4. Unpack dir_block.zip directly to c:\
 5. Start Nginx:
    c:\nginx_start.bat
 6. Start PHP 7.2.10
    c:\php72_start.bat
 7. Open Microsoft Edge and go to:
    http://localhost/
 8. You should see
    7.2.10
 9. Try to delete directory:
    c:\nginx\html
10. YES, YOU CAN
11. Restore deleted directory from dir_block.zip:
    c:\nginx\html
12. Stop PHP 7.2.10
    c:\php7x_stop.bat
13. Start PHP 7.3RC2
    c:\php73_start.bat
14. Open Microsoft Edge and go to:
    http://localhost/
15. You should see
    7.3RC2
16. Try to delete directory:
    c:\nginx\html
17. UPS, YOU CAN NOT!!!
 [2018-09-30 18:02 UTC] bugzilla77 at gmail dot com
>> You say regression.
PHP 7.2 OK
PHP 7.3 bug
 [2018-09-30 18:19 UTC] bugzilla77 at gmail dot com
>> Are you sure the problem is not that you have PHP running as a different user, and the created file has ownership/permissions set that you cannot remove it and thus cannot delete its parent directory?

File can be deleted. Only directory is blocked.
 [2018-09-30 18:20 UTC] bugzilla77 at gmail dot com
File can be deleted.
Only directory is blocked until you stop PHP service.
 [2018-10-02 22:22 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8209a8821cc934f81ffaa46dd8b0d0f2f546211f
Log: Fixed bug #76947 file_put_contents() blocks the directory of the file (__DIR__)
 [2018-10-02 22:22 UTC] ab@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 07:01:29 2024 UTC