thobbs / phpcassa

PHP client library for Apache Cassandra
thobbs.github.com/phpcassa
MIT License
248 stars 78 forks source link

Recursing too deep in ColumnFamilyIterator->next() #54

Closed maxwheeler closed 12 years ago

maxwheeler commented 12 years ago

If a CF query results in many empty (tombstone) rows then next() will call itself too many times and fault with the following error.

Fatal error: Maximum function nesting level of '100' reached, aborting! in /util/phpcassa/columnfamily.php on line 1222

Call Stack:

0.1746 10349728 5. ColumnFamilyIterator->next() /util/phpcassa/columnfamily.php:1231 0.1746 10349864 6. ColumnFamilyIterator->next() /util/phpcassa/columnfamily.php:1231 0.1746 10350000 7. ColumnFamilyIterator->next() /util/phpcassa/columnfamily.php:1231 The problem occurs on line 1229 below: ``` if (count(current($this->current_buffer)) == 0) { # this is an empty row, skip it $key = key($this->current_buffer); $this->next(); } ``` When there are lots of empty rows $this->next() keeps getting called until it goes too deep and dies.
maxwheeler commented 12 years ago

This patch seems to fix the problem but I haven't done extensive testing.

--- a/util/phpcassa/columnfamily.php +++ b/util/phpcassa/columnfamily.php @@ -1225,21 +1225,28 @@ class ColumnFamilyIterator implements Iterator { if (count(current($this->current_buffer)) == 0) {

this is an empty row, skip it

- $beyond_last_row = !isset($key);

thobbs commented 12 years ago

Would you mind opening a pull request for this? You can find instructions here: http://help.github.com/send-pull-requests/

This is definitely a bug, and I appreciate you taking the time to come up with a patch. Thanks!

maxwheeler commented 12 years ago

done, pull request sent