Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.15

Bug #4095 System::rm does not handle links correctly
Submitted: 2005-04-07 07:16 UTC
From: alan_k Assigned: cellog
Status: Closed Package: PEAR
PHP Version: 4.3.10 OS: linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 45 - 11 = ?

 
 [2005-04-07 07:16 UTC] alan_k
Description: ------------ in _multipleToStruct() the test if (is_dir($file)) { should be something like: if (is_dir($file) && !is_link($file)) { ** this needs testing/thinking about on win32.. the loop for retrieving files is also potentially buggy: in _dirToStruct() while ($file = readdir($dir)) { should read while (false !== ($file = readdir($dir))) { so that a file call 0 will not stop the list. Reproduce code: --------------- deleting softlinked folders deleting folders with a file called '0' in them.

Comments

 [2005-04-07 14:33 UTC] cellog
Hi Alan, Do you think you could whip up a .phpt that tests for both problems? Don't worry about skipif for windows, I'll figure that out, just need some basic code that sets up the error condition, and then I can fix the problems. win32 doesn't really have links, so that should be no problem. Shortcuts aren't as seamless, if you try to delete one, it deletes the shortcut and not what it points to.
 [2005-04-08 02:48 UTC] alan_k
I've not tested it, but this should do the job. <?php `mkdir /tmp/system_link_test`; `touch /tmp/system_link_test/0`; `touch /tmp/system_link_test/1`; `mkdir /tmp/system_link_test/sub1`; `mkdir /tmp/system_link_test/sub1/sub2`; `cp -la /tmp/system_link_test/sub1 /tmp/system_link_test/link2`; require_once 'System.php'; System::rm(array('-r','/tmp/system_link_test')); if (file_exists('/tmp/system_link_test')) { echo "TEST FAILED"; exit; } echo "TEST SUCCEEDED"; ?> --EXPECT-- TEST SUCCEEDED
 [2005-04-15 04:46 UTC] cellog
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.
 [2005-08-22 23:23 UTC] jstump
Index: System.php ============================================================ ======= RCS file: /repository/pear-core/System.php,v retrieving revision 1.48 diff -r1.48 System.php 58c58 < * @version Release: @package_version@ --- > * @version Release: 1.4.0b1 141c141 < if (is_dir($path)) { --- > if (is_dir($path) && !is_link($path)) {
 [2005-08-22 23:23 UTC] jstump
Index: bug4095.phpt ============================================================ ======= RCS file: /repository/pear-core/tests/System/bug4095.phpt,v retrieving revision 1.1 diff -r1.1 bug4095.phpt 16c16,17 < `cp -la /tmp/system_link_test/sub1 /tmp/system_link_test/ link2`; --- > `ln -s /tmp/system_link_test/sub1 /tmp/system_link_test/ link2`; > 18a20 > 27c29 < TEST SUCCEEDED \ No newline at end of file --- > TEST SUCCEEDED
 [2005-08-22 23:25 UTC] jstump
Alan, I changed the cp -l to ln -s because cp on some UNIX systems doesn't support -l, while ln -s is pretty standard. Also, added an is_link() check to _dirToStruct() to fix a small bug where it was ignoring links. --Joe
 [2005-08-23 00:37 UTC] cellog
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. fixed (again)