{"action":"closed","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/8498","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/8498/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/8498/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/8498/events","html_url":"https://github.com/yiisoft/yii2/issues/8498","id":78546997,"number":8498,"title":"behavior if you are cloning an AR object","user":{"login":"ItsReddi","id":3147888,"avatar_url":"https://avatars.githubusercontent.com/u/3147888?v=3","gravatar_id":"","url":"https://api.github.com/users/ItsReddi","html_url":"https://github.com/ItsReddi","followers_url":"https://api.github.com/users/ItsReddi/followers","following_url":"https://api.github.com/users/ItsReddi/following{/other_user}","gists_url":"https://api.github.com/users/ItsReddi/gists{/gist_id}","starred_url":"https://api.github.com/users/ItsReddi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ItsReddi/subscriptions","organizations_url":"https://api.github.com/users/ItsReddi/orgs","repos_url":"https://api.github.com/users/ItsReddi/repos","events_url":"https://api.github.com/users/ItsReddi/events{/privacy}","received_events_url":"https://api.github.com/users/ItsReddi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-20T14:26:18Z","updated_at":"2015-05-21T09:41:50Z","closed_at":"2015-05-21T09:41:50Z","body":"if youre cloning an AR object the cloned one is still the same as the original in the case of updating or inserting\r\nyou have to set `isNewRecord = false` and PK to `null`\r\n\r\nexample\r\n```\r\n$model = User::find('id = 1')->one();\r\n$modelClone = clone $model;\r\n$modelClone->attribute = 'xyz';\r\n$modelClone->save();\r\n```\r\n\r\nexpected (in my case) = new record\r\nreal behavior = $model is updated\r\n\r\nthis behavior has two sides on the one hand clone is working as expected because the object is cloned as normal but on the otherhand its also expected that the object is a new row.\r\n\r\nMaybe a discussion for 2.1?"}}