| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2008-04-04 13:02 UTC] graham at wyenet dot net
 Description:
------------
unlink() function will erase full (or empty) directories, where permissions are ok.
This actually breaks test suite, test copy_variation4.phpt which creates null files. The unlink actually removes the ext/standard/tests/file directory and then of course the test suits crashes out.
Reproduce code:
---------------
<?php
  unlink("test");
?>
Expected result:
----------------
PHP 5.2.3 on Solaris gives the following error.
[function.unlink]: Not owner in test.php
Although it would make more sence to be
[function.unlink]: Is directory in test.php
Actual result:
--------------
directory test is erased without warning, even if there are files present in the directory. fsck will recover the files. It wont break ownership permissions, and it wont erase directories containing file which where ownership permissions come into place.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 10:00:02 2025 UTC | 
$ php -r 'unlink("ttt");' Warning: unlink(ttt): Is a directory in Command line code on line 1 Perhaps Solaris unlink() actually allows unlinking directories? PHP just wraps around the libc unlink() so..According to unlink(2) manpage on Solaris: If the path argument is a directory and the filesystem sup- ports unlink() and unlinkat() on directories, the directory is unlinked from its parent with no cleanup being performed. In UFS, the disconnected directory will be found the next time the filesystem is checked with fsck(1M). The issue does only exist with a Solaris box using UFS and when run as "root" user. That's Solaris' behaviour where PHP has no influence. Marking as bogus therefore.