sheevazz / searchable-behaviour-for-cakephp

Automatically exported from code.google.com/p/searchable-behaviour-for-cakephp
0 stars 0 forks source link

Doesn't work with TreeBehavior, plus primary key issue #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If you use TreeBehavior at the same time as Searchable, you may get index 
records inserted into 
the index that have a blank association_key fields.

This is because for some reason TreeBehaviour unsets the primary key field in 
its beforeSave 
method.

I had a small discussion here http://groups.google.com/group/cake-
php/browse_thread/thread/76b6bf743e6e996/45cddc5bfc65000f

AD7six suggests that this behaviour should really look at Model->id rather than 
$data[model][id]

I'm not sure why TreeBehaviour feels the need to interfere with the data array 
so it could actually 
be a problem with TreeBehaviour for all I know. But you can fix it by either 
putting TreeBehaviour 
last in yout actsAs array, or probably by making the change AD7six proposes to 
this behaviour.

Also, I assume this behaviour will not work with models that have a primary key 
other than ID, as 
'id' is used everywhere in the code. It would be better to replace all those 
with Model-
>primaryKey, although I suspect AD7six's change would fix that too.

Original issue reported on code.google.com by jamierm...@gmail.com on 14 Oct 2008 at 9:10

GoogleCodeExporter commented 9 years ago
I believe this issue should be closed/fixed now, as the behavior is using $this-
>model->primaryKey to get the right ID for the model.

Original comment by sense...@gmail.com on 17 Jun 2009 at 11:22

GoogleCodeExporter commented 9 years ago

Original comment by calin....@gmail.com on 17 Jun 2009 at 11:52