Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthortom
     

    Hi,

    In my app, I have a Customers class which is derived from ActiveRecord. There, I declare:

    var $belongs_to = array( 'customer_group', 'country' );

    Now in a customer edit form, I need a select box for all existing customergroups and one for all existing countries. So in my helper, I do:

    $group_options = $this->_controller->CustomerGroup->collect( $this->_controller->CustomerGroup->find('all'), 'id', 'name' );

    which works fine. But

    $country_options = $this->_controller->Country->collect( $this->_controller->Country->find('all'), 'id', 'name' );

    which should do quite the same, only for a different table, produces this error:

    Fatal error: You are calling recursivelly AkActiveRecord::getAttribute by placing parent::getAttribute() or parent::get() on your model "getId" method. In order to avoid this, set the 2nd paramenter of parent::getAttribute to FALSE. If this was the behaviour you expected, please define the constant AK_ACTIVE_RECORD_PROTECT_GET_RECURSION and set it to false in /home/tom/Develop/eclipse/workspace/Akelos/lib/AkActiveRecord.php on line 1780

    Why? :)

    Cheers: Tom

    •  
      CommentAuthorbermi
     

    Tom,

    If you have AK_ACTIVE_RECORD_ENABLE_CALLBACK_GETTERS set to true in order to automatically trigger methods like

    Country::getName()
    

    Enabling that behaviour can cause unexpected reentrant bugs that are hard to find, so there is a recursion protection mechanism which raises an error in case you recurse too much (66 calls to the same getter)

    You can disable the warning as the error indicates by defining in your config.php

    define('AK_ACTIVE_RECORD_PROTECT_GET_RECURSION', false);
    

    Regards,

    Bermi

    • CommentAuthorwill
     

    I realize this thread may be dead, but I am having a similar problem.

    I seem to be unable to make any sort of 'find all' call with conditions without running into this same error.

    I've been trying are all sorts of permutations of find all. For example:

    $this->example =& $this->Example->find('all', array('conditions' => $this->searchCol .' like  \\'%' .$this->searchFor .'%\\''));
    

    or

    $this->example =& $this->Example->find('all', array('conditions' => 'id > 0 '));    //just testing
    

    I've tried writing out literal SQL expressions in the conditions and I've also tried using findBySQL.

    Every time, if the find retrieves numerous results, it generates the error after about 66 calls. (And with fewer results, everything works fine.)

    I understand that I can disable the warning, but what I don't understand is how to avoid making the 66+ calls. Why do they appear in a find all with conditions and not in the generic find all of the default "listing" function?

    I have not set AK_ACTIVE_RECORD_ENABLE_CALLBACK_GETTERS to true and I even tried overtly setting it to false in config.php to see if that would make a difference. It didn't.

    Any ideas?

    • CommentAuthorKaste
     

    can you nail this down. write a test? I cant remote-debug.

    • CommentAuthorwill
     

    Kaste,

    Thanks for replying.

    My problem, which I have just today solved (to a degree), stemmed from not merging the pagination_helper's find options with my own search conditions. Sort of a combination of suggestions that can be found here and here.

    The issue remains, I think, for situations where a find all call with conditions returns more than 65 results. I believe this can be easily reproduced by doing a find all with any sort of conditions (so that the sql produced looks like "SELECT * from table WHERE ...") and setting the paginator to show 70 or so items. In my experience with two separate akelos based apps, this was sufficient to trigger the error message.

    In sum, I don't know that the problem is an 'error', but it's definitely something to keep in mind when using find all calls. By keeping the results to less than 66, it seems avoidable. (In my case, since the paginator's options weren't kicking in, I was passing this limit on some searches.)

    For what it's worth, here's the code that's working for me now:

    $sql = $this->searchCol ." like "'%" .$this->searchFor ."%'";
    
    $this->example_pages = $this->pagination_helper->getPaginator($this->Example, array('items_per_page' => 25, 'count_conditions' => $sql ));
    
    $conds = array('conditions' => $sql);
    $options = array_merge( $conds, $this->pagination_helper->getFindOptions($this->Example));
    
    $this->example =& $this->Example->find('all', $options);
    

    Thanks.

    Will

    • CommentAuthorKaste
     

    that 'error' should be treated as a warning. You should definitely

     define('AK_ACTIVE_RECORD_PROTECT_GET_RECURSION', false);
    

    on production mode.

    I think we should consider to remove this warning.