Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.7

Request #18038 Reaching the set limit should not generate an error
Submitted: 2010-11-09 22:04 UTC
From: cl1mh4224rd Assigned: till
Status: Closed Package: Mail_Queue (version 1.2.6)
PHP Version: 5.2.9 OS:
Roadmaps: 1.2.7    
Subscription  


 [2010-11-09 22:04 UTC] cl1mh4224rd (Ryan Lange)
Description: ------------ In Mail_Queue 1.2.5, I believe, code was introduced into the Mail_Queue_Container::get() method that returns an error object when the queue has reached the limit that the user sets. (Lines 126-131 in Mail/Queue/Container.php) To make matters worse, the error object's code is set to MAILQUEUE_ERROR_CANNOT_INITIALIZE. This makes it impossible to distinguish from legitimate errors. The problem is most obvious when you've set up logging of error conditions, as an "error" log event will be generated each time the limit is met, despite this being a normal, expected situation. Possible solutions are to 1) simply return FALSE, or 2) add a new error code (i.e. MAILQUEUE_ERROR_LIMIT_REACHED) and set the instantiated error object's code to this value. I feel that this situation should not be considered an error condition, so #1 is ideal, in my opinion, but #2 may be an acceptable alternative.

Comments

 [2010-12-29 02:54 UTC] kqc9do4b (kq do)
I generally agree with the original comment which said that Mail_Queue_Container::get() should simply return false when a limit is reached. As it presently stands (v. 1.2.6), the while loop in Mail_Queue::sendMailsInQueue() never terminates (infinite loop) when the limit is reached, because the loop tests for the return of 'false' without testing for the possible return of an error object: while ($mail = $this->get()) { $this->container->countSend($mail);
 [2011-03-11 23:10 UTC] till (Till Klampaeckel)
-Assigned To: +Assigned To: till
 [2011-03-11 23:28 UTC] till (Till Klampaeckel)
The infinite loop is fixed in SVN. As for the constant. I can't change that now because it's been there for a while and this would mean a BC break. So I made another fix so that the error object is returned to you guys. Having done this it's easier (not ideal, but easier) to check the error message: "Cannot preload items: limit". if (Pear::isError($obj)) { if ($obj->getMessage() == 'Cannot preload items: limit') { ... } }
 [2011-03-11 23:28 UTC] till (Till Klampaeckel)
-Status: Assigned +Status: Closed
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.