Hi group!
My first post to this list so here goes...
I may have found a bug in the recover method in Tree.php, cake 1.3.2.
I was getting an SQL error when calling recover:
SQL Error: 1062: Duplicate entry '20' for key 'PRIMARY'
Here is an example of the SQL:
UPDATE `categories` SET `id` = 20, `parent_id` = 17, `name` = 'Beauty
tools', `lft` = 1, `rght` = 2 WHERE `categories`.`id` = 4
Obviously this is wrong since it's trying to update the id which is
the primary key.
The error pointed to:
TreeBehavior::recover() - CORE/cake/libs/model/behaviors/tree.php,
line 606
I made debug prints on the variables used before the save method
called on line 606 and noticed that the $Model->id was different from
the id in $Model->data. In fact, the $Model->data contained a
completely different object than the one with the current id.
So I added:
$Model->data = $array;
on line 604 and now it works. The tree is updated with correct lfts
and rghts.
The tree is a small one with about 20 nodes and it has correct
parent_ids.
Haven't dug any deeper in to this than the above. I've executed the
individual test case: libs/model/behaviors/tree.test.php before and
after the change and it passes both times.
Erik S.
@erikstarck
http://www.softwaresweden.com
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en