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

Bug #10247 unnecessary calls to die()
Submitted: 2007-03-02 14:22 UTC Modified: 2007-05-20 13:21 UTC
From: mkirk at cs dot umn dot edu Assigned: pfischer
Status: Closed Package: File_Archive (version 1.5.3)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2007-03-02 14:22 UTC] mkirk at cs dot umn dot edu (Mike)
Description: ------------ It seems reasonable that all calls to die could be replaced with PEAR::raiseError() Specifically, I am handling the case when attempting to extract a gzipped file as a tar-gzip. I encounter the line die('Checksum error on entry '.$this->currentFilename); The script shouldn't just halt, but return a useful error. There are calls to die on line 205 in Archive/Reader/Tar.php and on line 70 in Archive/Reader/Concat.php Test script: --------------- //since uploaded files are given a random name //without a useful extension, we can't extract from //an uploaded archive. $naive_reader = File_Archive::readUploadedFile('submitted_file'); //re-read the file reader with a specified extension $archive = File_Archive::readArchive( $file_extension='tgz' , $naive_reader ); $dir_writer = File_Archive::appender($dir = 'submissions'); $error = File_Archive::extract( $archive , $dir_writer); if( PEAR::isError( $error) ) { echo "there was an error detected, couldnt extract"; } else { echo "archive was extracted"; } Expected result: ---------------- echo either "there was an error detected, couldnt extract" or echo "archive was extracted" Actual result: -------------- this call to die from line 205 in Archive/Reader/Tar.php die('Checksum error on entry '.$this->currentFilename);

Comments

 [2007-05-20 04:49 UTC] doconnor (Daniel O'Connor)
Tar.php * swaps to 4 space soft tab * uses PEAR::raiseError()
 [2007-05-20 05:02 UTC] doconnor (Daniel O'Connor)
How much effort would it be to refactor to some kind of factory method, so you can return a PEAR_Error or an instanceOf File_Archive_Reader_Concat?
 [2007-05-20 13:21 UTC] pfischer (Pablo Fischer)
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. For CS and PEAR error I've commited the patch to CVS. For the factory stuff... IIRC File_Archive main class was 'designed' to be used as a factory class, so you don't need to include 'manually' other Reader/Writer classes.