{"action":"created","issue":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/12706","repository_url":"https://api.github.com/repos/cakephp/cakephp","labels_url":"https://api.github.com/repos/cakephp/cakephp/issues/12706/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/12706/comments","events_url":"https://api.github.com/repos/cakephp/cakephp/issues/12706/events","html_url":"https://github.com/cakephp/cakephp/issues/12706","id":377572103,"node_id":"MDU6SXNzdWUzNzc1NzIxMDM=","number":12706,"title":"TreeBehavior: Decrease default Priority for beforeDelete-Event","user":{"login":"3811015","id":19705939,"node_id":"MDQ6VXNlcjE5NzA1OTM5","avatar_url":"https://avatars3.githubusercontent.com/u/19705939?v=4","gravatar_id":"","url":"https://api.github.com/users/3811015","html_url":"https://github.com/3811015","followers_url":"https://api.github.com/users/3811015/followers","following_url":"https://api.github.com/users/3811015/following{/other_user}","gists_url":"https://api.github.com/users/3811015/gists{/gist_id}","starred_url":"https://api.github.com/users/3811015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3811015/subscriptions","organizations_url":"https://api.github.com/users/3811015/orgs","repos_url":"https://api.github.com/users/3811015/repos","events_url":"https://api.github.com/users/3811015/events{/privacy}","received_events_url":"https://api.github.com/users/3811015/received_events","type":"User","site_admin":false},"labels":[{"id":60504544,"node_id":"MDU6TGFiZWw2MDUwNDU0NA==","url":"https://api.github.com/repos/cakephp/cakephp/labels/Defect","name":"Defect","color":"f7c6c7","default":false},{"id":60504144,"node_id":"MDU6TGFiZWw2MDUwNDE0NA==","url":"https://api.github.com/repos/cakephp/cakephp/labels/Enhancement","name":"Enhancement","color":"bfe5bf","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-11-05T20:36:34Z","updated_at":"2018-11-05T22:22:27Z","closed_at":"2018-11-05T21:14:31Z","author_association":"NONE","body":"This is a (multiple allowed):\r\n\r\n* [x] bug\r\n* [x] enhancement\r\n* [ ] feature-discussion (RFC)\r\n\r\n* CakePHP Version: 3.5.6\r\n* Platform and Target: LAMP, debian 9, not so relevant\r\n\r\n### What you did\r\nI have a Model which uses TreeBehavior. And I use to push changes to the on-Device offline-First caches of an App.\r\nSo I created the default way a beforeDelete Event in the table, which pushed Ids which had deleted to the apps. I put the finder for children in there, which searches for chidren using the \"lft\" and \"rght\" fields to know the Ids of the children deleted with the entity.\r\n\r\n### What happened\r\nThe apps got pushed that the next root-nodes of the MPTT got deleted. They actually didnt get deleted. But a lot of apps deleted them from their offline-first-caches.\r\nWhat i figured out: my beforeDelete from the Table got fired after the beforeDelete of TreeBehavior. Searching for children beetwen lft and rght returns the next nodes which got reassigned the MPTT.\r\n\r\n### What you expected to happen\r\nI'd expect beforeDelete beeing really before anything is deleted.\r\n\r\nKind of very weird if you are not so much used to MPTT and you think your lft/rght is corrupt so you walk the long way of inspecting 12.000 records manually.\r\n\r\n_Proposed Easy fix:_\r\n- Lower the priority, so that treeBehavior::beforeDelete gets significant priority difference to any costum Events and \r\n- document how to deal with this this in the cookbook. (contributed a note already here: https://github.com/cakephp/docs/pull/5886)\r\n\r\n_Proposed Long fix:_\r\n\r\n- Implement new livecycle callbacks for TreeBehaviour in the ORM like ```afterChildrenDelete``` or ```beforeMainEntityDelete```."},"comment":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/comments/436057896","html_url":"https://github.com/cakephp/cakephp/issues/12706#issuecomment-436057896","issue_url":"https://api.github.com/repos/cakephp/cakephp/issues/12706","id":436057896,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNjA1Nzg5Ng==","user":{"login":"3811015","id":19705939,"node_id":"MDQ6VXNlcjE5NzA1OTM5","avatar_url":"https://avatars3.githubusercontent.com/u/19705939?v=4","gravatar_id":"","url":"https://api.github.com/users/3811015","html_url":"https://github.com/3811015","followers_url":"https://api.github.com/users/3811015/followers","following_url":"https://api.github.com/users/3811015/following{/other_user}","gists_url":"https://api.github.com/users/3811015/gists{/gist_id}","starred_url":"https://api.github.com/users/3811015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3811015/subscriptions","organizations_url":"https://api.github.com/users/3811015/orgs","repos_url":"https://api.github.com/users/3811015/repos","events_url":"https://api.github.com/users/3811015/events{/privacy}","received_events_url":"https://api.github.com/users/3811015/received_events","type":"User","site_admin":false},"created_at":"2018-11-05T22:22:27Z","updated_at":"2018-11-05T22:22:27Z","author_association":"NONE","body":"> I'm not convinced we need different priorities per callback, at least I've not seen a use case that required it.\r\n\r\nWell I need to push the Ids of the children in on creation and deletion. It did work great all the time on creation. Because the Behavior was first. Now it fails on the deletion. Increasing the priority of the Behavior would make it fail on the other end."}}
{"actor":{"display_login":"3811015"}}