cvs: pear /Mail_Queue Queue.php package.xml

[email protected] ("Lorenzo Alberton") Sun, 04 May 2008 08:26:45 -0000
Newsgroups php.pear.cvs
Message-ID <cvsquipo1209889605@cvsserver>
quipo		Sun May  4 08:26:45 2008 UTC

  Modified files:              
    /pear/Mail_Queue	Queue.php package.xml 
  Log:
  - fixed license
  - removed duplicate code
  - added error checking
  
http://cvs.php.net/viewvc.cgi/pear/Mail_Queue/Queue.php?r1=1.24&r2=1.25&diff_format=u
Index: pear/Mail_Queue/Queue.php
diff -u pear/Mail_Queue/Queue.php:1.24 pear/Mail_Queue/Queue.php:1.25
--- pear/Mail_Queue/Queue.php:1.24	Wed Mar  5 11:15:26 2008
+++ pear/Mail_Queue/Queue.php	Sun May  4 08:26:45 2008
@@ -3,12 +3,12 @@
 // +----------------------------------------------------------------------+
 // | PEAR :: Mail :: Queue                                                |
 // +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2007 The PHP Group                                |
+// | Copyright (c) 1997-2008 Radek Maciaszek, Lorenzo Alberton            |
 // +----------------------------------------------------------------------+
-// | This source file is subject to version 3.0 of the PHP license,       |
+// | This source file is subject to version 3.01 of the PHP license,      |
 // | that is bundled with this package in the file LICENSE, and is        |
 // | available at through the world-wide-web at                           |
-// | http://www.php.net/license/3_0.txt.                                  |
+// | http://www.php.net/license/3_01.txt.                                 |
 // | If you did not receive a copy of the PHP license and are unable to   |
 // | obtain it through the world-wide-web, please send a note to          |
 // | [email protected] so we can mail you a copy immediately.               |
@@ -17,7 +17,7 @@
 // |          Lorenzo Alberton <[email protected]>                      |
 // +----------------------------------------------------------------------+
 //
-// $Id: Queue.php,v 1.24 2008/03/05 11:15:26 quipo Exp $
+// $Id: Queue.php,v 1.25 2008/05/04 08:26:45 quipo Exp $
 
 /**
 * Class for handle mail queue managment.
@@ -98,8 +98,8 @@
 * // end usage example
 * -------------------------------------------------------------------------
 *
-* @version $Revision: 1.24 $
-* $Id: Queue.php,v 1.24 2008/03/05 11:15:26 quipo Exp $
+* @version $Revision: 1.25 $
+* $Id: Queue.php,v 1.25 2008/05/04 08:26:45 quipo Exp $
 * @author Radek Maciaszek <[email protected]>
 */
 
@@ -150,7 +150,7 @@
  * Mail_Queue - base class for mail queue managment.
  *
  * @author   Radek Maciaszek <[email protected]>
- * @version  $Id: Queue.php,v 1.24 2008/03/05 11:15:26 quipo Exp $
+ * @version  $Id: Queue.php,v 1.25 2008/05/04 08:26:45 quipo Exp $
  * @package  Mail_Queue
  * @access   public
  */
@@ -311,14 +311,8 @@
         while ($mail = $this->get()) {
             $this->container->countSend($mail);
 
-            $result = $this->sendMail($mail);
-
-            if (!PEAR::isError($result)) {
-                $this->container->setAsSent($mail);
-                if ($mail->isDeleteAfterSend()) {
-                    $this->deleteMail($mail->getId());
-                }
-            } else {
+            $result = $this->sendMail($mail, true);
+            if (PEAR::isError($result)) {
                 //remove the problematic mail from the buffer, but don't delete
                 //it from the db: it might be a temporary issue.
                 $this->container->skip();
@@ -327,6 +321,8 @@
                     MAILQUEUE_ERROR_CANNOT_SEND_MAIL, PEAR_ERROR_TRIGGER,
                     E_USER_NOTICE
                 );
+            } else if ($mail->isDeleteAfterSend()) {
+                $this->deleteMail($mail->getId());
             }
         }
         if (!empty($this->mail_options['persist']) && is_object($this->send_mail)) {
@@ -350,11 +346,10 @@
     function sendMailById($id, $set_as_sent=true)
     {
         $mail =& $this->container->getMailById($id);
-        $sent = $this->sendMail($mail);
-        if (!PEAR::isError($sent) && $sent && $set_as_sent) {
-            $this->container->setAsSent($mail);
+        if (PEAR::isError($mail)) {
+            return $mail;
         }
-        return $sent;
+        return $this->sendMail($mail, $set_as_sent);
     }
 
     // }}}
@@ -499,8 +494,8 @@
             $value = $value->getCode();
         }
 
-        return(isset($errorMessages[$value]) ?
-           $errorMessages[$value] : $errorMessages[MAILQUEUE_ERROR]);
+        return isset($errorMessages[$value]) ?
+           $errorMessages[$value] : $errorMessages[MAILQUEUE_ERROR];
     }
 
     // }}}
http://cvs.php.net/viewvc.cgi/pear/Mail_Queue/package.xml?r1=1.40&r2=1.41&diff_format=u
Index: pear/Mail_Queue/package.xml
diff -u pear/Mail_Queue/package.xml:1.40 pear/Mail_Queue/package.xml:1.41
--- pear/Mail_Queue/package.xml:1.40	Sat May  3 15:32:26 2008
+++ pear/Mail_Queue/package.xml	Sun May  4 08:26:45 2008
@@ -49,6 +49,7 @@
 - fixed bug #12521: NOTICE: undefined index
 - fixed bug #12768: On errors, sendMail() marks mail as sent anyway
 - better error handling in the MDB2 container
+- code cleanup
     </notes>
 	<contents>
 		<dir name="/">