{"action":"created","issue":{"url":"https://api.github.com/repos/OrchardCMS/OrchardCore/issues/1298","repository_url":"https://api.github.com/repos/OrchardCMS/OrchardCore","labels_url":"https://api.github.com/repos/OrchardCMS/OrchardCore/issues/1298/labels{/name}","comments_url":"https://api.github.com/repos/OrchardCMS/OrchardCore/issues/1298/comments","events_url":"https://api.github.com/repos/OrchardCMS/OrchardCore/issues/1298/events","html_url":"https://github.com/OrchardCMS/OrchardCore/pull/1298","id":282310373,"number":1298,"title":"Fixes duplicate version number + others suggestions.","user":{"login":"jtkech","id":8586360,"avatar_url":"https://avatars1.githubusercontent.com/u/8586360?v=4","gravatar_id":"","url":"https://api.github.com/users/jtkech","html_url":"https://github.com/jtkech","followers_url":"https://api.github.com/users/jtkech/followers","following_url":"https://api.github.com/users/jtkech/following{/other_user}","gists_url":"https://api.github.com/users/jtkech/gists{/gist_id}","starred_url":"https://api.github.com/users/jtkech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtkech/subscriptions","organizations_url":"https://api.github.com/users/jtkech/orgs","repos_url":"https://api.github.com/users/jtkech/repos","events_url":"https://api.github.com/users/jtkech/events{/privacy}","received_events_url":"https://api.github.com/users/jtkech/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-12-15T03:34:49Z","updated_at":"2017-12-16T00:15:30Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/OrchardCMS/OrchardCore/pulls/1298","html_url":"https://github.com/OrchardCMS/OrchardCore/pull/1298","diff_url":"https://github.com/OrchardCMS/OrchardCore/pull/1298.diff","patch_url":"https://github.com/OrchardCMS/OrchardCore/pull/1298.patch"},"body":"I tried to use the simplest way.\r\n\r\n1. In `DefaultContentManagerSession` which is a scoped service, items are cached by various states, `Id`, `ContentItemId` & `Number`, `Published`. In a previous PR i was thinking to remove an item from the cache when the related state is updated. But finally, for simplicity we can assume that the methods which modify these states are intended to be called at the end of a request. **So, that's ok for me**.\r\n\r\n2. In `BuildNewVersionAsync()`, even it is only called on a `Latest and Published` item (which is session saved before), we still check if it is the `Latest` and if not we are doing a `query`. So, assuming that this could be possible in the future, because we modify the queried item, i added a `_session.Save()`.\r\n\r\n3. Then, to fix the duplicate version number which happens after having discarding a draft, so the `Published` item becomes the `Latest` but not with the highest `Number`, here the suggestion is to simply also assign to this `Published` item the `Number` of the draft we are discarding + 1."},"comment":{"url":"https://api.github.com/repos/OrchardCMS/OrchardCore/issues/comments/352143163","html_url":"https://github.com/OrchardCMS/OrchardCore/pull/1298#issuecomment-352143163","issue_url":"https://api.github.com/repos/OrchardCMS/OrchardCore/issues/1298","id":352143163,"user":{"login":"jtkech","id":8586360,"avatar_url":"https://avatars1.githubusercontent.com/u/8586360?v=4","gravatar_id":"","url":"https://api.github.com/users/jtkech","html_url":"https://github.com/jtkech","followers_url":"https://api.github.com/users/jtkech/followers","following_url":"https://api.github.com/users/jtkech/following{/other_user}","gists_url":"https://api.github.com/users/jtkech/gists{/gist_id}","starred_url":"https://api.github.com/users/jtkech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtkech/subscriptions","organizations_url":"https://api.github.com/users/jtkech/orgs","repos_url":"https://api.github.com/users/jtkech/repos","events_url":"https://api.github.com/users/jtkech/events{/privacy}","received_events_url":"https://api.github.com/users/jtkech/received_events","type":"User","site_admin":false},"created_at":"2017-12-16T00:15:30Z","updated_at":"2017-12-16T00:15:30Z","author_association":"MEMBER","body":"Finally i like the idea of removing the `Number` property.\r\n\r\nSo i did it, can be reverted just to show it.\r\n\r\nOnly one doubt at the beginning of the content manager `Create()` method.\r\n\r\n            if (contentItem.Number == 0)\r\n            {\r\n                contentItem.Number = 1;\r\n                contentItem.Latest = true;\r\n                contentItem.Published = true;\r\n            }\r\n\r\nNot sure i understand, is it possible to do a `Create()` by passing an item with `Number != 0`?\r\n\r\nIf it is only to check if the item has no related database record, i think the following is ok.\r\n\r\n            if (contentItem.Id == 0)\r\n            {\r\n                contentItem.Latest = true;\r\n                contentItem.Published = true;\r\n            }\r\n"}}
{"actor":{"display_login":"jtkech"}}