PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_AJAX » Bug #9020

logical bug in ordered queue code

Details

Submitted2006-10-13 22:29 UTC
Fromjfillman at cucbc dot com
Assignedauroraeosrose
StatusClosed
PackageHTML_AJAX
PHP Version4.3.2
OSRHEL 3
Roadmaps0.5.1

Comments

[2006-10-13 22:29 UTC] jfillman at cucbc dot com

Description:
------------
I found a bug in the logic of the ordered Queue.

If a number of items in the queue come back out of order, the callback function for the last item in the queue never gets called.

It's too dificult for me to illustrate the exact senario's that cause the bug but it will occur consistantly if the requests in the queue come back in this order:

1 2 5 4 3
or
1 2 3 5 4
or
1 2 4 3 5

the bug is in the processCallback function in the HTML_AJAX_Queue_Ordered class.

here's the original code:

processCallback: function(result,order) {
if (order == this.current) {
this.callbacks[order](result);
this.current++;
}
else {
this.interned[order] = result;
if (this.interned[this.current]) {
this.callbacks[this.current](this.interned[this.current]);
this.current++;
}
}
}

and here's the new function that seems to be working for me:

processCallback: function(result,order) {
if (order == this.current) {
this.callbacks[order](result);
this.current++;
}
else {
this.interned[order] = result;
}
while (this.interned[this.current]) {
this.callbacks[this.current](this.interned[this.current]);
this.current++;
}
}