Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Bug #19473: PEAR::isError() compatibility problem with PHP 5.4

  • Loading branch information...
commit fc6e3f769a5f653e1385fabafe8bd37731583f02 1 parent 81ca7ef
Aleksander Machniak alecpl authored
Showing with 65 additions and 16 deletions.
  1. +24 −7 Mail/mime.php
  2. +22 −5 Mail/mimePart.php
  3. +19 −4 package.xml
31 Mail/mime.php
View
@@ -245,7 +245,7 @@ function setTXTBody($data, $isfile = false, $append = false)
}
} else {
$cont = $this->_file2str($data);
- if (PEAR::isError($cont)) {
+ if ($this->isError($cont)) {
return $cont;
}
if (!$append) {
@@ -286,7 +286,7 @@ function setHTMLBody($data, $isfile = false)
$this->_htmlbody = $data;
} else {
$cont = $this->_file2str($data);
- if (PEAR::isError($cont)) {
+ if ($this->isError($cont)) {
return $cont;
}
$this->_htmlbody = $cont;
@@ -336,7 +336,7 @@ function addHTMLImage($file,
$filedata = null;
$bodyfile = $file;
} else {
- if (PEAR::isError($filedata = $this->_file2str($file))) {
+ if ($this->isError($filedata = $this->_file2str($file))) {
return $filedata;
}
}
@@ -416,7 +416,7 @@ function addAttachment($file,
$filedata = null;
$bodyfile = $file;
} else {
- if (PEAR::isError($filedata = $this->_file2str($file))) {
+ if ($this->isError($filedata = $this->_file2str($file))) {
return $filedata;
}
}
@@ -719,7 +719,7 @@ function getMessage($separation = null, $params = null, $headers = null,
$body = $this->get($params);
- if (PEAR::isError($body)) {
+ if ($this->isError($body)) {
return $body;
}
@@ -1020,7 +1020,7 @@ function &get($params = null, $filename = null, $skip_head = false)
if ($filename) {
// Append mimePart message headers and body into file
$headers = $message->encodeToFile($filename, $boundary, $skip_head);
- if (PEAR::isError($headers)) {
+ if ($this->isError($headers)) {
return $headers;
}
$this->_headers = array_merge($this->_headers, $headers);
@@ -1028,7 +1028,7 @@ function &get($params = null, $filename = null, $skip_head = false)
return $ret;
} else {
$output = $message->encode($boundary, $skip_head);
- if (PEAR::isError($output)) {
+ if ($this->isError($output)) {
return $output;
}
$this->_headers = array_merge($this->_headers, $output['headers']);
@@ -1473,4 +1473,21 @@ function _checkParams()
}
}
+ /**
+ * PEAR::isError wrapper
+ *
+ * @param mixed $data Object
+ *
+ * @return bool True if object is an instance of PEAR_Error
+ */
+ private function isError($data)
+ {
+ // PEAR::isError() is not PHP 5.4 compatible (see Bug #19473)
+ if (is_object($data) && is_a($data, 'PEAR_Error')) {
+ return true;
+ }
+
+ return false;
+ }
+
} // End of class
27 Mail/mimePart.php
View
@@ -315,7 +315,7 @@ function encode($boundary=null)
for ($i = 0; $i < count($this->_subparts); $i++) {
$encoded['body'] .= '--' . $boundary . $eol;
$tmp = $this->_subparts[$i]->encode();
- if (PEAR::isError($tmp)) {
+ if ($this->isError($tmp)) {
return $tmp;
}
foreach ($tmp['headers'] as $key => $value) {
@@ -338,7 +338,7 @@ function encode($boundary=null)
@ini_set('magic_quotes_runtime', $magic_quote_setting);
}
- if (PEAR::isError($body)) {
+ if ($this->isError($body)) {
return $body;
}
$encoded['body'] = $body;
@@ -390,7 +390,7 @@ function encodeToFile($filename, $boundary=null, $skip_head=false)
@ini_set('magic_quotes_runtime', $magic_quote_setting);
}
- return PEAR::isError($res) ? $res : $this->_headers;
+ return $this->isError($res) ? $res : $this->_headers;
}
/**
@@ -425,7 +425,7 @@ function _encodePartToFile($fh, $boundary=null, $skip_head=false)
for ($i = 0; $i < count($this->_subparts); $i++) {
fwrite($fh, $f_eol . '--' . $boundary . $eol);
$res = $this->_subparts[$i]->_encodePartToFile($fh);
- if (PEAR::isError($res)) {
+ if ($this->isError($res)) {
return $res;
}
$f_eol = $eol;
@@ -440,7 +440,7 @@ function _encodePartToFile($fh, $boundary=null, $skip_head=false)
$res = $this->_getEncodedDataFromFile(
$this->_body_file, $this->_encoding, $fh
);
- if (PEAR::isError($res)) {
+ if ($this->isError($res)) {
return $res;
}
}
@@ -1225,4 +1225,21 @@ function _encodeReplaceCallback($matches)
return sprintf('%%%02X', ord($matches[1]));
}
+ /**
+ * PEAR::isError wrapper
+ *
+ * @param mixed $data Object
+ *
+ * @return bool True if object is an instance of PEAR_Error
+ */
+ private function isError($data)
+ {
+ // PEAR::isError() is not PHP 5.4 compatible (see Bug #19473)
+ if (is_object($data) && is_a($data, 'PEAR_Error')) {
+ return true;
+ }
+
+ return false;
+ }
+
} // End of class
23 package.xml
View
@@ -29,9 +29,9 @@ using RFC2047 and/or RFC2231.</description>
<email>alec@php.net</email>
<active>yes</active>
</lead>
- <date>2012-06-09</date>
+ <date>2012-07-09</date>
<version>
- <release>1.8.5</release>
+ <release>1.8.6</release>
<api>1.4.3</api>
</version>
<stability>
@@ -40,8 +40,7 @@ using RFC2047 and/or RFC2231.</description>
</stability>
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license>
<notes>
- * Added possibility to set additional parameters of message part header, e.g. attachment size [alec]
- * Added automatic setting of attachment size via Content-Disposition header size parameter [alec]
+* Bug #19473: PEAR::isError() compatibility problem with PHP 5.4 [alec]
</notes>
<contents>
<dir name="/">
@@ -652,5 +651,21 @@ Bugs Fixed:
* Fixed Bug #18982: Non-static method Mail_mimePart::encodeHeader() should not be called statically [alec]
</notes>
</release>
+ <release>
+ <date>2012-06-09</date>
+ <version>
+ <release>1.8.5</release>
+ <api>1.4.3</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license>
+ <notes>
+ * Added possibility to set additional parameters of message part header, e.g. attachment size [alec]
+ * Added automatic setting of attachment size via Content-Disposition header size parameter [alec]
+ </notes>
+ </release>
</changelog>
</package>
Please sign in to comment.
Something went wrong with that request. Please try again.