cnizzardini / cakephp-datatable

CakePHP Component for interoperability between CakePHP 2.x and jQuery DataTables plugin.
62 stars 49 forks source link

`getWhereConditions()` are incorrectly merged into `paginate['contain']` #35

Open fr0z3nfyr opened 7 years ago

fr0z3nfyr commented 7 years ago

Hi Chris - thanks for your efforts on this component. This one is an excellent starting point for me to build a complete plugin out of it. Anyway, just like you I'm also quite busy with projects at work, so it might be a while till I release a plugin(haven't decided yet whether I'll want to push incremental changes to this repo or create a new project and give you the major credit :smiley: )

Well now coming to the issue, I have noticed on line 101-102 that conditions are being merged into contain, probably a typo but that returns errors when I use contain in my controller find options. This is the code block:

        if(isset($httpGet) && !empty($httpGet['sSearch'])){
            $conditions = $this->getWhereConditions();

            if( !empty($this->controller->paginate['contain']) ){    // should be paginate['conditions']
                $this->controller->paginate = array_merge_recursive($this->controller->paginate, array('contain'=>$conditions));    // should be array('conditions' => $conditions)
            }
            else{    // this block seems perfectly fine
                $this->controller->paginate = array_merge_recursive($this->controller->paginate, array('conditions'=>array('AND'=>$conditions)));
            }
            $isFiltered = true;
        }

See my comments on code above. Please make/commit the changes and close the issue quickly.