{"action":"created","issue":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/9277","repository_url":"https://api.github.com/repos/cakephp/cakephp","labels_url":"https://api.github.com/repos/cakephp/cakephp/issues/9277/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/9277/comments","events_url":"https://api.github.com/repos/cakephp/cakephp/issues/9277/events","html_url":"https://github.com/cakephp/cakephp/issues/9277","id":171348580,"number":9277,"title":"Related data not marked as dirty when patching 1:1 association","user":{"login":"antograssiot","id":4977112,"avatar_url":"https://avatars.githubusercontent.com/u/4977112?v=3","gravatar_id":"","url":"https://api.github.com/users/antograssiot","html_url":"https://github.com/antograssiot","followers_url":"https://api.github.com/users/antograssiot/followers","following_url":"https://api.github.com/users/antograssiot/following{/other_user}","gists_url":"https://api.github.com/users/antograssiot/gists{/gist_id}","starred_url":"https://api.github.com/users/antograssiot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antograssiot/subscriptions","organizations_url":"https://api.github.com/users/antograssiot/orgs","repos_url":"https://api.github.com/users/antograssiot/repos","events_url":"https://api.github.com/users/antograssiot/events{/privacy}","received_events_url":"https://api.github.com/users/antograssiot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cakephp/cakephp/labels/Defect","name":"Defect","color":"f7c6c7"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/cakephp/cakephp/milestones/98","html_url":"https://github.com/cakephp/cakephp/milestones/3.3.1","labels_url":"https://api.github.com/repos/cakephp/cakephp/milestones/98/labels","id":1939998,"number":98,"title":"3.3.1","description":"Minor features and bugfixes for 3.3.x","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":37,"closed_issues":16,"state":"open","created_at":"2016-08-13T02:01:49Z","updated_at":"2016-08-16T14:50:15Z","due_on":"2016-08-26T00:00:00Z","closed_at":null},"comments":2,"created_at":"2016-08-16T08:05:56Z","updated_at":"2016-08-16T17:10:51Z","closed_at":null,"body":"This is a (multiple allowed):\r\n* [x] bug\r\n* [ ] enhancement\r\n* [ ] feature-discussion (RFC)\r\n\r\n* CakePHP Version: 3.3.0\r\n\r\nthis is an extension of #9267 for 1:1 association\r\n\r\n### What you did\r\n```php\r\nclass UsersController extends AppController\r\n{\r\n    public function profile()\r\n    {\r\n        $user = $this->Users->get($this->Auth->user('id'), [\r\n            'contain' => ['Profiles']\r\n        ]);\r\n        if ($this->request->is(['patch', 'post', 'put'])) {\r\n            $user = $this->Users->patchEntity($user, $this->request->data);\r\n            if ($this->Users->save($user)) {\r\n                $this->Flash->success(__(\"Yay\"));\r\n            } else {\r\n                $this->Flash->error(__(\"Derp\"));\r\n            }\r\n        }\r\n        $this->set(compact('user'));\r\n    }\r\n}\r\n```\r\n\r\n```php\r\nclass UsersTable extends Table\r\n{\r\n    public function initialize(array $config)\r\n    {\r\n        $this->hasOne('Profiles', [\r\n            'dependent' => true\r\n        ]);\r\n    }\r\n}\r\n```\r\n\r\n```php\r\nclass ProfilesTable extends Table\r\n{\r\n    public function initialize(array $config)\r\n    {\r\n        $this->belongsTo('Users', [\r\n            'foreignKey' => 'user_id',\r\n            'joinType' => 'INNER'\r\n        ]);\r\n    }\r\n}\r\n```\r\n### Expected Behavior\r\nThe profile entity is being updated when posting data like \r\n```php\r\n[\r\n    'id' => 'fafde4e3-25b1-4869-94b6-1b8530e663cf',\r\n    'profile' => [\r\n        'firstname' => 'ADMIN',\r\n        'lastname' => 'ISTRATOR',\r\n        'notification' => 1\r\n    ],\r\n    'email' => 'new@email.com',\r\n]\r\n```\r\n\r\n### Actual Behavior\r\nThe Profile entity not being updated.Its fields are mark as dirty but 'profile' is not dirty in the user entity\r\n\r\n```\r\nobject(App\\Model\\Entity\\User) {\r\n\r\n       \t'id' => 'f6ae698f-3ce1-400f-b218-eda119718e73',\r\n       \t'email' => 'new@email.com',\r\n       \t'profile' => object(App\\Model\\Entity\\Profile) {\r\n       \t\t'id' => (int) 11,\r\n       \t\t'user_id' => 'f6ae698f-3ce1-400f-b218-eda119718e73',\r\n       \t\t'firstname' => 'ADMIN',\r\n       \t\t'lastname' => 'ISTRATEUR',\r\n       \t\t'notification' => true,\r\n       \t\t'[new]' => false,\r\n       \t\t'[accessible]' => [\r\n       \t\t\t'user_id' => true,\r\n       \t\t\t'firstname' => true,\r\n       \t\t\t'lastname' => true,\r\n       \t\t\t'notification' => true\r\n       \t\t],\r\n       \t\t'[dirty]' => [\r\n       \t\t\t'firstname' => true,\r\n       \t\t\t'lastname' => true,\r\n       \t\t],\r\n       \t\t'[original]' => [\r\n       \t\t\t'firstname' => 'AD',\r\n       \t\t\t'lastname' => 'MIN',\r\n       \t\t],\r\n       \t\t'[virtual]' => [],\r\n       \t\t'[errors]' => [],\r\n       \t\t'[invalid]' => [],\r\n       \t\t'[repository]' => 'Profiles'\r\n\r\n       \t},\r\n       \t'[new]' => false,\r\n       \t'[accessible]' => [\r\n       \t\t'profile' => true,\r\n       \t\t'email' => true\r\n       \t],\r\n       \t'[dirty]' => [\r\n       \t\t'email' => true\r\n       \t],\r\n       \t'[original]' => [\r\n       \t\t'email' => 'admin@admin.fr'\r\n       \t],\r\n       \t'[virtual]' => [],\r\n       \t'[errors]' => [],\r\n       \t'[invalid]' => [],\r\n       \t'[repository]' => 'Users'\r\n}\r\n```\r\n\r\n\r\nAs you can see, `profile` is not added in as `dirty` in the `User` entity  after patching and therefore is not saved.\r\n\r\nThe previous patch did not solved this case, and I didn't found any existing test that covers this scenario.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/comments/240170416","html_url":"https://github.com/cakephp/cakephp/issues/9277#issuecomment-240170416","issue_url":"https://api.github.com/repos/cakephp/cakephp/issues/9277","id":240170416,"user":{"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},"created_at":"2016-08-16T17:10:51Z","updated_at":"2016-08-16T17:10:51Z","body":"Thanks for the test @antograssiot I'll get it fixed."}}
{"actor":{"display_login":"markstory"}}