FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=18512&edit=1

ID: 18512
Updated by: mrook@php.net
Reported By: jacek_nowaczyk at o2 dot pl
Summary: dead links are not saved in tar file
-Status: Analyzed
+Status: Closed
Type: Bug
Package: Archive_Tar
Operating System: ALL
Package Version: 1.3.7
PHP Version: 5.3.6
-Assigned To:
+Assigned To: mrook
-Roadmap Versions:
+Roadmap Versions: 1.3.8
New Comment:

-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!


Previous Comments:
------------------------------------------------------------------------

[2011-05-29 17:56:57] jacu

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-05-29 14:02:06] doconnor

-Status: Open
+Status: Analyzed


------------------------------------------------------------------------

[2011-05-29 14:01:52] doconnor

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-09 12:24:58] jacu

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;
}

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJun 1, '11 at 12:17p
activeJun 1, '11 at 12:17p
posts1
users1
websitepear.php.net

1 user in discussion

Mrook: 1 post

People

Translate

site design / logo © 2022 Grokbase