Home » Mail » Mail_Queue » Bug #7903
Put method sec_to_send to acting as expected
Details
| Submitted | 2006-06-15 01:04 UTC |
|---|---|
| From | pierre2543 at hotmail dot com |
| Assigned | quipo |
| Status | Closed |
| Package | Mail_Queue |
| PHP Version | 4.4.0 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2006-06-15 01:04 UTC] pierre2543 at hotmail dot com
Description:
------------
put method not treating sec_to_send as expected.
If you leave the value to default (ie: sec_to_send = 0), and try to send during the same second that the put was done, the email won't be sent.
From the docs it appears that if sec_to_send is 0 and you try to send right away, the email should be sent. This however is not what happens. The code at fault is in db.php, other containers may have same problem.
Here's the diff of the fix (nothing complicated):
--- db.php 2006-06-14 20:41:46.000000000 -0400
+++ db.php.bkp 2006-06-14 20:39:20.000000000 -0400
@@ -115,7 +115,7 @@
{
$query = sprintf("SELECT * FROM %s WHERE sent_time IS NULL
AND try_sent < %d
- AND %s >= time_to_send
+ AND %s > time_to_send
ORDER BY time_to_send",
$this->mail_table,
$this->try,
@@ -353,4 +353,4 @@
// }}}
}
Test script:
---------------
$db =& DB::connect($dsn);
$myQueue =& new Mail_Queue( $dbOption, $mailOptions);
/* clear the queue */
$result =& $db->query('delete from mail_queue;');
/* add a message */
$myQueue->put(
'from@domain.ext',
'to@domain.ext',
NULL,
'some text',
0); //Seconds to pass before delivery is attempted
/* send it */
$myQueue->sendMailsInQueue();
/* check the size of queue */
$result =& $db->query('select count(*) from mail_queue;');
$row = $result->fetchRow();
echo "Size of queue: ", $row[0];
Expected result:
----------------
Size of queue: 0
Actual result:
--------------
- Output prior to patch (if insert and send happen during the same second)
Size of queue: 1
- Output after patch
Size of queue: 0