FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=18038&edit=1

ID: 18038
Updated by: till@php.net
Reported By: ryan dot m dot lange at gmail dot com
Summary: Reaching the set limit should not generate an error
Status: Open
Type: Feature/Change Request
Package: Mail_Queue
Package Version: 1.2.6
PHP Version: 5.2.9
-Assigned To:
+Assigned To: till
Roadmap Versions:
New Comment:

-Assigned To:
+Assigned To: till



Previous Comments:
------------------------------------------------------------------------

[2010-12-28 21:54:41] kqc9do4b

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);

------------------------------------------------------------------------

[2010-11-09 17:04:58] cl1mh4224rd

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.

------------------------------------------------------------------------

Search Discussions

  • Till at Mar 11, 2011 at 5:25 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18038&edit=1

    ID: 18038
    Updated by: till@php.net
    Reported By: ryan dot m dot lange at gmail dot com
    Summary: Reaching the set limit should not generate an error
    Status: Assigned
    Type: Feature/Change Request
    Package: Mail_Queue
    Package Version: 1.2.6
    PHP Version: 5.2.9
    Assigned To: till
    Roadmap Versions:
    New Comment:

    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') {
    ...
    }
    }


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-03-11 18:10:45] till

    -Assigned To:
    +Assigned To: till


    ------------------------------------------------------------------------

    [2010-12-28 21:54:41] kqc9do4b

    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);

    ------------------------------------------------------------------------

    [2010-11-09 17:04:58] cl1mh4224rd

    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.

    ------------------------------------------------------------------------
  • Till at Mar 11, 2011 at 5:25 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18038&edit=1

    ID: 18038
    Updated by: till@php.net
    Reported By: ryan dot m dot lange at gmail dot com
    Summary: Reaching the set limit should not generate an error
    -Status: Assigned
    +Status: Closed
    Type: Feature/Change Request
    Package: Mail_Queue
    Package Version: 1.2.6
    PHP Version: 5.2.9
    Assigned To: till
    Roadmap Versions:
    New Comment:

    -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.




    Previous Comments:
    ------------------------------------------------------------------------

    [2011-03-11 18:28:26] till

    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 18:10:45] till

    -Assigned To:
    +Assigned To: till


    ------------------------------------------------------------------------

    [2010-12-28 21:54:41] kqc9do4b

    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);

    ------------------------------------------------------------------------

    [2010-11-09 17:04:58] cl1mh4224rd

    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.

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedMar 11, '11 at 5:07p
activeMar 11, '11 at 5:25p
posts3
users1
websitepear.php.net

1 user in discussion

Till: 3 posts

People

Translate

site design / logo © 2022 Grokbase