{"action":"created","comment":{"url":"https://api.github.com/repos/cakephp/cakephp/pulls/comments/43831016","id":43831016,"diff_hunk":"@@ -406,25 +410,31 @@ function ($v) {\n      * @param array $foreignKey array of foreign key properties\n      * @param Table $target The associated table\n      * @param array $conditions The conditions that specifies what are the objects to be unlinked\n-     * @return void\n+     * @return bool success\n      */\n     protected function _unlink(array $foreignKey, Table $target, array $conditions = [])\n     {\n+        $ok = true;\n         $mustBeDependent = (!$this->_foreignKeyAcceptsNull($target, $foreignKey) || $this->dependent());\n-        if ($mustBeDependent) {\n-            if ($this->_cascadeCallbacks) {\n-                $query = $this->find('all')->where($conditions);\n-                foreach ($query as $assoc) {\n-                    $target->delete($assoc);\n+        $persistedEntitiesExist = $this->exists($conditions);\n+\n+        if ($persistedEntitiesExist) {\n+            if ($mustBeDependent) {\n+                if ($this->_cascadeCallbacks) {\n+                    $query = $this->find('all')->where($conditions);\n+                    foreach ($query as $assoc) {\n+                        $ok = $ok && $target->delete($assoc);\n+                    }\n+                } else {\n+                    $ok = ($target->deleteAll($conditions) > 0);\n                 }\n             } else {\n-                $target->deleteAll($conditions);\n-            }\n-        } else {\n-            $updateFields = array_fill_keys($foreignKey, null);\n-            $target->updateAll($updateFields, $conditions);\n+                $updateFields = array_fill_keys($foreignKey, null);\n+                $ok = $target->updateAll($updateFields, $conditions);","path":"src/ORM/Association/HasMany.php","position":null,"original_position":66,"commit_id":"c99a54fe037638dfd08b6d91459f15567e6de6b7","original_commit_id":"9a853a187a13a33a4631715aa26cdd49db0e7f25","user":{"login":"mylux","id":11030522,"avatar_url":"https://avatars.githubusercontent.com/u/11030522?v=3","gravatar_id":"","url":"https://api.github.com/users/mylux","html_url":"https://github.com/mylux","followers_url":"https://api.github.com/users/mylux/followers","following_url":"https://api.github.com/users/mylux/following{/other_user}","gists_url":"https://api.github.com/users/mylux/gists{/gist_id}","starred_url":"https://api.github.com/users/mylux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mylux/subscriptions","organizations_url":"https://api.github.com/users/mylux/orgs","repos_url":"https://api.github.com/users/mylux/repos","events_url":"https://api.github.com/users/mylux/events{/privacy}","received_events_url":"https://api.github.com/users/mylux/received_events","type":"User","site_admin":false},"body":"Done!","created_at":"2015-11-04T01:09:10Z","updated_at":"2015-11-04T01:09:10Z","html_url":"https://github.com/cakephp/cakephp/pull/7632#discussion_r43831016","pull_request_url":"https://api.github.com/repos/cakephp/cakephp/pulls/7632","_links":{"self":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/comments/43831016"},"html":{"href":"https://github.com/cakephp/cakephp/pull/7632#discussion_r43831016"},"pull_request":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/7632"}}},"pull_request":{"url":"https://api.github.com/repos/cakephp/cakephp/pulls/7632","id":49385728,"html_url":"https://github.com/cakephp/cakephp/pull/7632","diff_url":"https://github.com/cakephp/cakephp/pull/7632.diff","patch_url":"https://github.com/cakephp/cakephp/pull/7632.patch","issue_url":"https://api.github.com/repos/cakephp/cakephp/issues/7632","number":7632,"state":"open","locked":false,"title":"HasMany associations take failures into consideration when performing replace operations","user":{"login":"mylux","id":11030522,"avatar_url":"https://avatars.githubusercontent.com/u/11030522?v=3","gravatar_id":"","url":"https://api.github.com/users/mylux","html_url":"https://github.com/mylux","followers_url":"https://api.github.com/users/mylux/followers","following_url":"https://api.github.com/users/mylux/following{/other_user}","gists_url":"https://api.github.com/users/mylux/gists{/gist_id}","starred_url":"https://api.github.com/users/mylux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mylux/subscriptions","organizations_url":"https://api.github.com/users/mylux/orgs","repos_url":"https://api.github.com/users/mylux/repos","events_url":"https://api.github.com/users/mylux/events{/privacy}","received_events_url":"https://api.github.com/users/mylux/received_events","type":"User","site_admin":false},"body":"Solution for the issue #7588\r\n@ndm2 , is this what you were expecting? ","created_at":"2015-11-02T00:25:44Z","updated_at":"2015-11-04T01:09:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"df1f28857a0036850e00abf2b9a89235eb1925d6","assignee":null,"milestone":{"url":"https://api.github.com/repos/cakephp/cakephp/milestones/64","html_url":"https://github.com/cakephp/cakephp/milestones/3.1.3","labels_url":"https://api.github.com/repos/cakephp/cakephp/milestones/64/labels","id":1362733,"number":64,"title":"3.1.3","description":"Bugfixes and minor features for the 3.1.x release branch","creator":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"open_issues":22,"closed_issues":45,"state":"open","created_at":"2015-10-19T01:08:03Z","updated_at":"2015-11-03T17:21:26Z","due_on":"2015-11-04T05:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/cakephp/cakephp/pulls/7632/commits","review_comments_url":"https://api.github.com/repos/cakephp/cakephp/pulls/7632/comments","review_comment_url":"https://api.github.com/repos/cakephp/cakephp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/7632/comments","statuses_url":"https://api.github.com/repos/cakephp/cakephp/statuses/c99a54fe037638dfd08b6d91459f15567e6de6b7","head":{"label":"mylux:issue-7588","ref":"issue-7588","sha":"c99a54fe037638dfd08b6d91459f15567e6de6b7","user":{"login":"mylux","id":11030522,"avatar_url":"https://avatars.githubusercontent.com/u/11030522?v=3","gravatar_id":"","url":"https://api.github.com/users/mylux","html_url":"https://github.com/mylux","followers_url":"https://api.github.com/users/mylux/followers","following_url":"https://api.github.com/users/mylux/following{/other_user}","gists_url":"https://api.github.com/users/mylux/gists{/gist_id}","starred_url":"https://api.github.com/users/mylux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mylux/subscriptions","organizations_url":"https://api.github.com/users/mylux/orgs","repos_url":"https://api.github.com/users/mylux/repos","events_url":"https://api.github.com/users/mylux/events{/privacy}","received_events_url":"https://api.github.com/users/mylux/received_events","type":"User","site_admin":false},"repo":{"id":43277823,"name":"cakephp","full_name":"mylux/cakephp","owner":{"login":"mylux","id":11030522,"avatar_url":"https://avatars.githubusercontent.com/u/11030522?v=3","gravatar_id":"","url":"https://api.github.com/users/mylux","html_url":"https://github.com/mylux","followers_url":"https://api.github.com/users/mylux/followers","following_url":"https://api.github.com/users/mylux/following{/other_user}","gists_url":"https://api.github.com/users/mylux/gists{/gist_id}","starred_url":"https://api.github.com/users/mylux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mylux/subscriptions","organizations_url":"https://api.github.com/users/mylux/orgs","repos_url":"https://api.github.com/users/mylux/repos","events_url":"https://api.github.com/users/mylux/events{/privacy}","received_events_url":"https://api.github.com/users/mylux/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mylux/cakephp","description":"CakePHP: The Rapid Development Framework for PHP - Official Repository","fork":true,"url":"https://api.github.com/repos/mylux/cakephp","forks_url":"https://api.github.com/repos/mylux/cakephp/forks","keys_url":"https://api.github.com/repos/mylux/cakephp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mylux/cakephp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mylux/cakephp/teams","hooks_url":"https://api.github.com/repos/mylux/cakephp/hooks","issue_events_url":"https://api.github.com/repos/mylux/cakephp/issues/events{/number}","events_url":"https://api.github.com/repos/mylux/cakephp/events","assignees_url":"https://api.github.com/repos/mylux/cakephp/assignees{/user}","branches_url":"https://api.github.com/repos/mylux/cakephp/branches{/branch}","tags_url":"https://api.github.com/repos/mylux/cakephp/tags","blobs_url":"https://api.github.com/repos/mylux/cakephp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mylux/cakephp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mylux/cakephp/git/refs{/sha}","trees_url":"https://api.github.com/repos/mylux/cakephp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mylux/cakephp/statuses/{sha}","languages_url":"https://api.github.com/repos/mylux/cakephp/languages","stargazers_url":"https://api.github.com/repos/mylux/cakephp/stargazers","contributors_url":"https://api.github.com/repos/mylux/cakephp/contributors","subscribers_url":"https://api.github.com/repos/mylux/cakephp/subscribers","subscription_url":"https://api.github.com/repos/mylux/cakephp/subscription","commits_url":"https://api.github.com/repos/mylux/cakephp/commits{/sha}","git_commits_url":"https://api.github.com/repos/mylux/cakephp/git/commits{/sha}","comments_url":"https://api.github.com/repos/mylux/cakephp/comments{/number}","issue_comment_url":"https://api.github.com/repos/mylux/cakephp/issues/comments{/number}","contents_url":"https://api.github.com/repos/mylux/cakephp/contents/{+path}","compare_url":"https://api.github.com/repos/mylux/cakephp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mylux/cakephp/merges","archive_url":"https://api.github.com/repos/mylux/cakephp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mylux/cakephp/downloads","issues_url":"https://api.github.com/repos/mylux/cakephp/issues{/number}","pulls_url":"https://api.github.com/repos/mylux/cakephp/pulls{/number}","milestones_url":"https://api.github.com/repos/mylux/cakephp/milestones{/number}","notifications_url":"https://api.github.com/repos/mylux/cakephp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mylux/cakephp/labels{/name}","releases_url":"https://api.github.com/repos/mylux/cakephp/releases{/id}","created_at":"2015-09-28T03:25:51Z","updated_at":"2015-09-28T03:26:07Z","pushed_at":"2015-11-04T01:08:14Z","git_url":"git://github.com/mylux/cakephp.git","ssh_url":"git@github.com:mylux/cakephp.git","clone_url":"https://github.com/mylux/cakephp.git","svn_url":"https://github.com/mylux/cakephp","homepage":"http://cakephp.org","size":87870,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cakephp:master","ref":"master","sha":"a448f49c89a6c430c5a99dd44a252e65eaa01b20","user":{"login":"cakephp","id":23666,"avatar_url":"https://avatars.githubusercontent.com/u/23666?v=3","gravatar_id":"","url":"https://api.github.com/users/cakephp","html_url":"https://github.com/cakephp","followers_url":"https://api.github.com/users/cakephp/followers","following_url":"https://api.github.com/users/cakephp/following{/other_user}","gists_url":"https://api.github.com/users/cakephp/gists{/gist_id}","starred_url":"https://api.github.com/users/cakephp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cakephp/subscriptions","organizations_url":"https://api.github.com/users/cakephp/orgs","repos_url":"https://api.github.com/users/cakephp/repos","events_url":"https://api.github.com/users/cakephp/events{/privacy}","received_events_url":"https://api.github.com/users/cakephp/received_events","type":"Organization","site_admin":false},"repo":{"id":656494,"name":"cakephp","full_name":"cakephp/cakephp","owner":{"login":"cakephp","id":23666,"avatar_url":"https://avatars.githubusercontent.com/u/23666?v=3","gravatar_id":"","url":"https://api.github.com/users/cakephp","html_url":"https://github.com/cakephp","followers_url":"https://api.github.com/users/cakephp/followers","following_url":"https://api.github.com/users/cakephp/following{/other_user}","gists_url":"https://api.github.com/users/cakephp/gists{/gist_id}","starred_url":"https://api.github.com/users/cakephp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cakephp/subscriptions","organizations_url":"https://api.github.com/users/cakephp/orgs","repos_url":"https://api.github.com/users/cakephp/repos","events_url":"https://api.github.com/users/cakephp/events{/privacy}","received_events_url":"https://api.github.com/users/cakephp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cakephp/cakephp","description":"CakePHP: The Rapid Development Framework for PHP - Official Repository","fork":false,"url":"https://api.github.com/repos/cakephp/cakephp","forks_url":"https://api.github.com/repos/cakephp/cakephp/forks","keys_url":"https://api.github.com/repos/cakephp/cakephp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cakephp/cakephp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cakephp/cakephp/teams","hooks_url":"https://api.github.com/repos/cakephp/cakephp/hooks","issue_events_url":"https://api.github.com/repos/cakephp/cakephp/issues/events{/number}","events_url":"https://api.github.com/repos/cakephp/cakephp/events","assignees_url":"https://api.github.com/repos/cakephp/cakephp/assignees{/user}","branches_url":"https://api.github.com/repos/cakephp/cakephp/branches{/branch}","tags_url":"https://api.github.com/repos/cakephp/cakephp/tags","blobs_url":"https://api.github.com/repos/cakephp/cakephp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cakephp/cakephp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cakephp/cakephp/git/refs{/sha}","trees_url":"https://api.github.com/repos/cakephp/cakephp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cakephp/cakephp/statuses/{sha}","languages_url":"https://api.github.com/repos/cakephp/cakephp/languages","stargazers_url":"https://api.github.com/repos/cakephp/cakephp/stargazers","contributors_url":"https://api.github.com/repos/cakephp/cakephp/contributors","subscribers_url":"https://api.github.com/repos/cakephp/cakephp/subscribers","subscription_url":"https://api.github.com/repos/cakephp/cakephp/subscription","commits_url":"https://api.github.com/repos/cakephp/cakephp/commits{/sha}","git_commits_url":"https://api.github.com/repos/cakephp/cakephp/git/commits{/sha}","comments_url":"https://api.github.com/repos/cakephp/cakephp/comments{/number}","issue_comment_url":"https://api.github.com/repos/cakephp/cakephp/issues/comments{/number}","contents_url":"https://api.github.com/repos/cakephp/cakephp/contents/{+path}","compare_url":"https://api.github.com/repos/cakephp/cakephp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cakephp/cakephp/merges","archive_url":"https://api.github.com/repos/cakephp/cakephp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cakephp/cakephp/downloads","issues_url":"https://api.github.com/repos/cakephp/cakephp/issues{/number}","pulls_url":"https://api.github.com/repos/cakephp/cakephp/pulls{/number}","milestones_url":"https://api.github.com/repos/cakephp/cakephp/milestones{/number}","notifications_url":"https://api.github.com/repos/cakephp/cakephp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cakephp/cakephp/labels{/name}","releases_url":"https://api.github.com/repos/cakephp/cakephp/releases{/id}","created_at":"2010-05-08T14:38:22Z","updated_at":"2015-11-03T13:33:25Z","pushed_at":"2015-11-04T01:08:20Z","git_url":"git://github.com/cakephp/cakephp.git","ssh_url":"git@github.com:cakephp/cakephp.git","clone_url":"https://github.com/cakephp/cakephp.git","svn_url":"https://github.com/cakephp/cakephp","homepage":"http://cakephp.org","size":186608,"stargazers_count":6134,"watchers_count":6134,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2809,"mirror_url":null,"open_issues_count":150,"forks":2809,"open_issues":150,"watchers":6134,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/7632"},"html":{"href":"https://github.com/cakephp/cakephp/pull/7632"},"issue":{"href":"https://api.github.com/repos/cakephp/cakephp/issues/7632"},"comments":{"href":"https://api.github.com/repos/cakephp/cakephp/issues/7632/comments"},"review_comments":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/7632/comments"},"review_comment":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/7632/commits"},"statuses":{"href":"https://api.github.com/repos/cakephp/cakephp/statuses/c99a54fe037638dfd08b6d91459f15567e6de6b7"}}}}