Home » File Formats » Archive_Tar » Bug #3911
Easier error reporting, no PEAR overhead if not needed.
Details
| Request #3911 | Easier error reporting, no PEAR overhead if not needed. |
|---|---|
| Submitted | 2005-03-22 08:38 UTC |
| From | makler at php dot net |
| Status | Wont fix |
| Package | Archive_Tar |
| PHP Version | 4.3.10 |
| OS | any |
| Roadmaps | (Not assigned) |
Comments
[2005-03-22 08:38 UTC] makler at php dot net
Description:
------------
I have no clue how can I find in easy way the error message that is set in Archive_Tar::_error() internal method.
I think the easier method would be to set an internal wariable of the Archive_Tar object. To more functions defined: getError() and getWarnings() are then defined.
No PEAR is needed for extracting a file - only when errors are encountered, PEAR is included with include_once from _error().
Reproduce code:
---------------
--- Tar.php.fixed Tue Mar 22 09:20:46 2005
+++ Tar.php.withoutpear Tue Mar 22 09:34:38 2005
@@ -21,2 +20,0 @@
-require_once 'PEAR.php';
-
@@ -30 +28 @@ require_once 'PEAR.php';
-class Archive_Tar extends PEAR
+class Archive_Tar
@@ -51,0 +50,10 @@ class Archive_Tar extends PEAR
+ /**
+ * @var object PEAR::Error object from the last call to _error().
+ */
+ var $_errormsg;
+
+ /**
+ * @var array Array of PEAR::Error objects set with calls to _warning().
+ */
+ var $_warningmsg=array();
+
@@ -66 +73,0 @@ class Archive_Tar extends PEAR
- $this->PEAR();
@@ -92 +98,0 @@ class Archive_Tar extends PEAR
- $this->_PEAR();
@@ -388 +394,2 @@ class Archive_Tar extends PEAR
- $this->raiseError($p_message);
+ include_once('PEAR.php');
+ $this->_errormsg = PEAR::raiseError($p_message);
@@ -395,2 +402,15 @@ class Archive_Tar extends PEAR
- // ----- To be completed
- $this->raiseError($p_message);
+ $this->_warningmsg[] = $p_message;
+ include_once('PEAR.php');
+ PEAR::raiseError($p_message);
+ }
+ // }}}
+
+ // {{{ getError()
+ function &getError() {
+ return $this->_errormsg;
+ }
+ // }}}
+
+ // {{{ getWarnings()
+ function &getWarnings() {
+ return $this->_warningmsg;