Sfoglia il codice sorgente

[ZF-9486] zend_mail_transport_sendmail::_sendMail() missing restore_error_handler() on exit path

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21603 44c647ce-9c0f-0410-b52a-842ac1e357ba
yoshida@zend.co.jp 16 anni fa
parent
commit
a3f66144e0
1 ha cambiato i file con 20 aggiunte e 18 eliminazioni
  1. 20 18
      library/Zend/Mail/Transport/Sendmail.php

+ 20 - 18
library/Zend/Mail/Transport/Sendmail.php

@@ -74,14 +74,14 @@ class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract
      */
     public function __construct($parameters = null)
     {
-		if ($parameters instanceof Zend_Config) { 
-			$parameters = $parameters->toArray(); 
-		}
-
-		if (is_array($parameters)) { 
-			$parameters = implode(' ', $parameters);
-		}
-		
+        if ($parameters instanceof Zend_Config) { 
+            $parameters = $parameters->toArray(); 
+        }
+
+        if (is_array($parameters)) { 
+            $parameters = implode(' ', $parameters);
+        }
+        
         $this->parameters = $parameters;
     }
 
@@ -97,35 +97,37 @@ class Zend_Mail_Transport_Sendmail extends Zend_Mail_Transport_Abstract
      */
     public function _sendMail()
     {
-        set_error_handler(array($this, '_handleMailErrors'));
         if ($this->parameters === null) {
+            set_error_handler(array($this, '_handleMailErrors'));
             $result = mail(
                 $this->recipients,
                 $this->_mail->getSubject(),
                 $this->body,
                 $this->header);
+            restore_error_handler();
         } else {
-        	if(!is_string($this->parameters)) {
-	            /**
-	             * @see Zend_Mail_Transport_Exception
-	             * 
-	             * Exception is thrown here because
-	             * $parameters is a public property
-	             */
+            if(!is_string($this->parameters)) {
+                /**
+                 * @see Zend_Mail_Transport_Exception
+                 * 
+                 * Exception is thrown here because
+                 * $parameters is a public property
+                 */
                 require_once 'Zend/Mail/Transport/Exception.php';
                 throw new Zend_Mail_Transport_Exception(
                     'Parameters were set but are not a string'
                 );
-        	}
+            }
 
+            set_error_handler(array($this, '_handleMailErrors'));
             $result = mail(
                 $this->recipients,
                 $this->_mail->getSubject(),
                 $this->body,
                 $this->header,
                 $this->parameters);
+            restore_error_handler();
         }
-        restore_error_handler();
 
         if ($this->_errstr !== null || !$result) {
             /**