Log message #4044944

# At Username Text
# Jun 27th 2017, 15:32 jeremyharris (I’m reading through the code atm)
# Jun 27th 2017, 15:32 jeremyharris I feel ya
# Jun 27th 2017, 15:32 elboletaire exactly that's how I've been the latest two ours...
# Jun 27th 2017, 15:31 jeremyharris hrm
# Jun 27th 2017, 15:31 elboletaire `replace`
# Jun 27th 2017, 15:30 jeremyharris what’s the saveStrategy?
# Jun 27th 2017, 15:30 elboletaire no relations are touched... the original relations remain the same
# Jun 27th 2017, 15:30 elboletaire in fact
# Jun 27th 2017, 15:30 elboletaire so both apparently are saving, but no relations are stored
# Jun 27th 2017, 15:30 elboletaire the link returns true, the `save` (using `set`) returns the entity
# Jun 27th 2017, 15:29 jeremyharris wait you said it’s returning true and fails to save?
# Jun 27th 2017, 15:29 jeremyharris also check the table rules
# Jun 27th 2017, 15:29 jeremyharris perhaps pepper the core with some debug statements, that’d be my next step. specifically where it returns false. one might be failing for some strange reason
# Jun 27th 2017, 15:28 elboletaire ofc
# Jun 27th 2017, 15:27 jeremyharris I’m assuming you debugged roles and users, and they have content
# Jun 27th 2017, 15:26 jeremyharris yeah actually; scratch that idea
# Jun 27th 2017, 15:26 elboletaire but, setting it to `dirty` is only needed if I'm trying to save new contained entities (roles in my case), right?
# Jun 27th 2017, 15:25 jeremyharris elboletaire they might be returning true if there is nothing to save, eg, no dirty properties
# Jun 27th 2017, 15:21 elboletaire btw, I'm using Cake 3.3.16, I don't know if there's any known issue related to this (I wasn't able to found it in github issues)
# Jun 27th 2017, 15:21 elboletaire but I don't feel very confortable using that approach, as both entities are already saved (using `_ids` seems like I'm adding much logic that can be ignored if I use `link`)
# Jun 27th 2017, 15:20 elboletaire yes
# Jun 27th 2017, 15:20 neon1024 Does it work if you build an array with _ids and use patchEntity() ?
# Jun 27th 2017, 15:19 elboletaire maybe I could debug it somehow? some protected property in the entity maybe?
# Jun 27th 2017, 15:19 neon1024 save() returns mixed if I recall, false or the data
# Jun 27th 2017, 15:19 neon1024 I would imagine that set() and link() return boolean as they’re just assigning things, so the boolean would be a ‘Yes Ive done this’ type return
# Jun 27th 2017, 15:18 elboletaire btw, either case works for me :( any ideas on why this apparently works (both `save` using `set` and `link` always return true), but it really doesn't?
# Jun 27th 2017, 15:17 elboletaire it's a bit more complicated than that... but it does internally `set` the related entities, and then runs `saveLinks`
# Jun 27th 2017, 15:17 neon1024 Oh right, okay :slightly_smiling_face:
# Jun 27th 2017, 15:17 elboletaire in fact, `link` does that internally afaik
# Jun 27th 2017, 15:16 elboletaire doesn't work either using `set`
# Jun 27th 2017, 15:16 neon1024 It’s the default too I think
# Jun 27th 2017, 15:16 neon1024 Cool, that’s the one I prefer. I find it simpler to deal with
# Jun 27th 2017, 15:16 elboletaire I've it in replace
# Jun 27th 2017, 15:16 neon1024 Probably worth checking the association saveStrategy too just in case
# Jun 27th 2017, 15:15 neon1024 Yep, and I would then expect it to create the join table records
# Jun 27th 2017, 15:15 elboletaire after `set` I should save the entity, right?
# Jun 27th 2017, 15:15 elboletaire hhmm I'll give it a try
# Jun 27th 2017, 15:15 neon1024 I’d probably get a list of role entities, and set it to user $user->set(‘roles’ => $arrayOfRoleEntities);
# Jun 27th 2017, 15:15 elboletaire how would you do this? linking existing entities with others before/after save?
# Jun 27th 2017, 15:14 neon1024 Sorry @elboletaire I’ve never used `link()` before, so can’t help with that :slightly_smiling_face:
# Jun 27th 2017, 15:10 slackebot success. Any ideas on what's failing? The piece of code is something like this: ```$roles = $entity->roles; $users = $this->Users->find()->where(['department_id' => $entity->id])->all(); foreach ($users as $user) { $this->Users->Roles->link($user, $roles); } ```