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

Bug #18512 dead links are not saved in tar file
Submitted: 2011-05-09 16:24 UTC
From: jacu Assigned: mrook
Status: Closed Package: Archive_Tar (version 1.3.7)
PHP Version: 5.3.6 OS: ALL
Roadmaps: 1.3.8    
Subscription  


 [2011-05-09 16:24 UTC] jacu (Jacek Nowaczyk)
Description: ------------ dead links are not saved in tar file - UNIX implementation stores link no matter target exists or not. Patch to fix this bug in test description. Test script: --------------- In function _addList(): is: if (!file_exists($v_filename)) { $this->_warning("File '$v_filename' does not exist"); continue; } supposed to be: if (!file_exists($v_filename) && !@is_link($v_filename)) { $this->_warning("File '$v_filename' does not exist"); continue; }

Comments

 [2011-05-29 18:01 UTC] doconnor (Daniel O'Connor)
Hi Jacek, Can you provide a small reproducible test case? The fix you describe is fine except for how you are suppressing errors on is_link. A quick test case which shows before/after behaviour + no regression would make me more comfortable applying this fix; or a fuller version of it which doesn't require error suppression.
 [2011-05-29 18:02 UTC] doconnor (Daniel O'Connor)
-Status: Open +Status: Analyzed
 [2011-05-29 21:56 UTC] jacu (Jacek Nowaczyk)
Hi Daniel, You are right - there is no need to suppress is_link warnings - there are no warnings to suppress there. I've added '@' probably because I was fixing this in emergency mode (missing link issue was reported by end users) and had no time to play with this. Here is a test case exposing the difference between Unix tar and PHP implementation. I've added exec tar to demonstrate that dead links are added without any message. I've added 'nonExisting' item to tar to demonstrate that it still works and to provide 100% branch coverage of modified block. It should be trivial to add it to regression. <?php //force error reporting error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); ini_set("display_errors", 1); require_once 'Archive/Tar.php'; PEAR::setErrorHandling (PEAR_ERROR_PRINT); //prepare filesystem mkdir('test'); mkdir('test/a'); touch('test/b'); symlink('a', 'test/dir_link'); symlink('b', 'test/file_link'); symlink('dead', 'test/dead_link'); //prepare reference tar system('tar -cf test1.tar test'); $tar1=new Archive_Tar('test1.tar'); $tar1List=array_map('fileName',$tar1->listContent()); //create tar $tar2=new Archive_Tar('test2.tar'); $tar2->create(array('test','nonExisting'));// to make sure we are still report nonExisting $tar2List=array_map('fileName',$tar2->listContent()); //compare results $diff=array_diff($tar1List, $tar2List); echo "\nReference:\n"; print_r($tar1List); echo "\nResult:\n"; print_r($tar2List); echo "\nTest status: "; echo (count($diff))?"FAILED\n":"OK\n"; function fileName($item){ return rtrim($item['filename'],'/').' => '.$item['link']; } ?>
 [2011-06-01 17:16 UTC] mrook (Michiel Rook)
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: mrook -Roadmap Versions: +Roadmap Versions: 1.3.8
This bug has been fixed in SVN. 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. Fix and (adapted) unit test added in r311709 - thanks!