I believe this is corrected by adding a primary id key to your mapping table.
On Oct 15, 7:33 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I finally opened my eyes and found the file model.php where all models > are defined for the tests. > > This bug is not caught by the tests since it appears to only happen > when the association is defined on both ends. > UserhabtmModule AND ModulehabtmUser. > or as in the core tests > ArticlehabtmTag AND TaghabtmArticle. > > Just in case anyone else runs into the same problem. > > /Martin > > On Oct 15, 2:43 pm, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > Hi, > > I have noticed that "toggling"HABTMassociations does not work for me > > anymore since rc3. Going back to rc2 makes everything work as > > expected. > > >https://trac.cakephp.org/ticket/5579 > > I found a ticket about the same problem. I am not able to get the test > > case for model.php to reproduce the behaviour so I must assume my > > toggle code is messed up in some way that now matters in rc3. I have a > > few problems trying to write a test for Model to reproduce this > > problem. > > > • I can't seem to find any actual classes (only fixtures). I.E. I > > can't locate where and how theHABTMis defined for Article and Tag in > > the tests. For example it apears that only ArticlehabtmTag and not > > the other way around? > > • The data being deleted does not affect the relationship between > > "this" Article and the Tags, it affects the other Articles that the > > "deleted" Tag is linked to. > > > Since the tests seem ok I am wondering if the bad guy is not either > > the table-definition for the linking table or the definition of the > >habtm? I was not able to vary either of these in the test. > > > This is my toggle method which links and unlinks Modules and Users. It > > has worked fine until rc3. > > I do not expect this code to cause the problem this time but you never > > know. (Yes I have used set() as-well but the results are the same) > > > function toggleModule($user, $module_id) { > > $new_mod = $this->Module->findById($module_id); > > if ( $new_mod ) { > > $existing_ids = Set::extract($user['Module'], '{n}.id'); > > if ( in_array($new_mod['Module']['id'], $existing_ids) ) { > > foreach ( $existing_ids as $i => $id ) { > > if ( $id == $new_mod['Module']['id'] ) { > > unset($existing_ids[$i]); > > } > > } > > } else { > > $existing_ids[] = $new_mod['Module']['id']; > > } > > unset($user['Module']); > > sort($existing_ids); > > $user['Module']['Module'] = $existing_ids; > > $this->save($user); > > return true; > > } else { > > return false; > > } > > > } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
