{"action":"created","comment":{"url":"https://api.github.com/repos/api-platform/core/pulls/comments/187047544","pull_request_review_id":118747263,"id":187047544,"diff_hunk":"@@ -481,4 +491,34 @@ protected function normalizeRelation(PropertyMetadata $propertyMetadata, $relate\n \n         return $iri;\n     }\n+\n+    /**\n+     * Populates the object if allowed to and not set already. If you pass identifiers, it will search for them, otherwise\n+     * fall back to the identifiersextractor.\n+     *\n+     * @param $data\n+     * @param $class\n+     * @param array $context\n+     * @param array $identifiers\n+     */\n+    protected function populateObjectIfAllowed($data, $class, array $context = [], array $identifiers = [])\n+    {\n+        if (!isset($context[self::OBJECT_TO_POPULATE])) {\n+            if (0 === count($identifiers)) {\n+                $identifiers = $this->identifiersExtractor->getIdentifiersFromResourceClass($class);\n+            }\n+\n+            if (0 !== count(array_intersect(array_keys($data), $identifiers))) {","path":"src/Serializer/AbstractItemNormalizer.php","position":62,"original_position":62,"commit_id":"6f0063ec52962cf2a173e5dc321c8a4abd7225ae","original_commit_id":"6f0063ec52962cf2a173e5dc321c8a4abd7225ae","user":{"login":"Toflar","id":481937,"avatar_url":"https://avatars2.githubusercontent.com/u/481937?v=4","gravatar_id":"","url":"https://api.github.com/users/Toflar","html_url":"https://github.com/Toflar","followers_url":"https://api.github.com/users/Toflar/followers","following_url":"https://api.github.com/users/Toflar/following{/other_user}","gists_url":"https://api.github.com/users/Toflar/gists{/gist_id}","starred_url":"https://api.github.com/users/Toflar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Toflar/subscriptions","organizations_url":"https://api.github.com/users/Toflar/orgs","repos_url":"https://api.github.com/users/Toflar/repos","events_url":"https://api.github.com/users/Toflar/events{/privacy}","received_events_url":"https://api.github.com/users/Toflar/received_events","type":"User","site_admin":false},"body":"I have no clue if this works, it was just a quick hack and needs to be covered by tests. The idea here is just to check if the data contains all identifiers.","created_at":"2018-05-09T13:54:38Z","updated_at":"2018-05-09T13:54:39Z","html_url":"https://github.com/api-platform/core/pull/1939#discussion_r187047544","pull_request_url":"https://api.github.com/repos/api-platform/core/pulls/1939","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/api-platform/core/pulls/comments/187047544"},"html":{"href":"https://github.com/api-platform/core/pull/1939#discussion_r187047544"},"pull_request":{"href":"https://api.github.com/repos/api-platform/core/pulls/1939"}}},"pull_request":{"url":"https://api.github.com/repos/api-platform/core/pulls/1939","id":186929222,"html_url":"https://github.com/api-platform/core/pull/1939","diff_url":"https://github.com/api-platform/core/pull/1939.diff","patch_url":"https://github.com/api-platform/core/pull/1939.patch","issue_url":"https://api.github.com/repos/api-platform/core/issues/1939","number":1939,"state":"open","locked":false,"title":"[WIP] Refactor population of object in serializer","user":{"login":"Toflar","id":481937,"avatar_url":"https://avatars2.githubusercontent.com/u/481937?v=4","gravatar_id":"","url":"https://api.github.com/users/Toflar","html_url":"https://github.com/Toflar","followers_url":"https://api.github.com/users/Toflar/followers","following_url":"https://api.github.com/users/Toflar/following{/other_user}","gists_url":"https://api.github.com/users/Toflar/gists{/gist_id}","starred_url":"https://api.github.com/users/Toflar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Toflar/subscriptions","organizations_url":"https://api.github.com/users/Toflar/orgs","repos_url":"https://api.github.com/users/Toflar/repos","events_url":"https://api.github.com/users/Toflar/events{/privacy}","received_events_url":"https://api.github.com/users/Toflar/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Bug fix?      | yes\r\n| New feature?  | no\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| Fixed tickets | #1937\r\n| License       | MIT\r\n| Doc PR        | \r\n\r\nThis is completely untested but I think it should be enough to outline the plan as described in https://github.com/api-platform/core/issues/1937\r\n\r\nBasically this would fix two things:\r\n\r\n* No more hardcoded dependency on `id` but using the `IdentifiersExtractor` instead.\r\n* It would actually fix #1937 because the serializers now test if the object even exists and only then disallow populating the object.\r\n\r\nLooking for feedback here :-)\r\n","created_at":"2018-05-09T13:53:48Z","updated_at":"2018-05-09T13:54:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1f029750cffb350d04577375216476ea7fa8dd10","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/api-platform/core/pulls/1939/commits","review_comments_url":"https://api.github.com/repos/api-platform/core/pulls/1939/comments","review_comment_url":"https://api.github.com/repos/api-platform/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/api-platform/core/issues/1939/comments","statuses_url":"https://api.github.com/repos/api-platform/core/statuses/6f0063ec52962cf2a173e5dc321c8a4abd7225ae","head":{"label":"Toflar:fix-allow-post-id","ref":"fix-allow-post-id","sha":"6f0063ec52962cf2a173e5dc321c8a4abd7225ae","user":{"login":"Toflar","id":481937,"avatar_url":"https://avatars2.githubusercontent.com/u/481937?v=4","gravatar_id":"","url":"https://api.github.com/users/Toflar","html_url":"https://github.com/Toflar","followers_url":"https://api.github.com/users/Toflar/followers","following_url":"https://api.github.com/users/Toflar/following{/other_user}","gists_url":"https://api.github.com/users/Toflar/gists{/gist_id}","starred_url":"https://api.github.com/users/Toflar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Toflar/subscriptions","organizations_url":"https://api.github.com/users/Toflar/orgs","repos_url":"https://api.github.com/users/Toflar/repos","events_url":"https://api.github.com/users/Toflar/events{/privacy}","received_events_url":"https://api.github.com/users/Toflar/received_events","type":"User","site_admin":false},"repo":{"id":109725903,"name":"api-platform-core","full_name":"Toflar/api-platform-core","owner":{"login":"Toflar","id":481937,"avatar_url":"https://avatars2.githubusercontent.com/u/481937?v=4","gravatar_id":"","url":"https://api.github.com/users/Toflar","html_url":"https://github.com/Toflar","followers_url":"https://api.github.com/users/Toflar/followers","following_url":"https://api.github.com/users/Toflar/following{/other_user}","gists_url":"https://api.github.com/users/Toflar/gists{/gist_id}","starred_url":"https://api.github.com/users/Toflar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Toflar/subscriptions","organizations_url":"https://api.github.com/users/Toflar/orgs","repos_url":"https://api.github.com/users/Toflar/repos","events_url":"https://api.github.com/users/Toflar/events{/privacy}","received_events_url":"https://api.github.com/users/Toflar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Toflar/api-platform-core","description":"The server component of API Platform: hypermedia and GraphQL APIs in minutes","fork":true,"url":"https://api.github.com/repos/Toflar/api-platform-core","forks_url":"https://api.github.com/repos/Toflar/api-platform-core/forks","keys_url":"https://api.github.com/repos/Toflar/api-platform-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Toflar/api-platform-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Toflar/api-platform-core/teams","hooks_url":"https://api.github.com/repos/Toflar/api-platform-core/hooks","issue_events_url":"https://api.github.com/repos/Toflar/api-platform-core/issues/events{/number}","events_url":"https://api.github.com/repos/Toflar/api-platform-core/events","assignees_url":"https://api.github.com/repos/Toflar/api-platform-core/assignees{/user}","branches_url":"https://api.github.com/repos/Toflar/api-platform-core/branches{/branch}","tags_url":"https://api.github.com/repos/Toflar/api-platform-core/tags","blobs_url":"https://api.github.com/repos/Toflar/api-platform-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Toflar/api-platform-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Toflar/api-platform-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/Toflar/api-platform-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Toflar/api-platform-core/statuses/{sha}","languages_url":"https://api.github.com/repos/Toflar/api-platform-core/languages","stargazers_url":"https://api.github.com/repos/Toflar/api-platform-core/stargazers","contributors_url":"https://api.github.com/repos/Toflar/api-platform-core/contributors","subscribers_url":"https://api.github.com/repos/Toflar/api-platform-core/subscribers","subscription_url":"https://api.github.com/repos/Toflar/api-platform-core/subscription","commits_url":"https://api.github.com/repos/Toflar/api-platform-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/Toflar/api-platform-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/Toflar/api-platform-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/Toflar/api-platform-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/Toflar/api-platform-core/contents/{+path}","compare_url":"https://api.github.com/repos/Toflar/api-platform-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Toflar/api-platform-core/merges","archive_url":"https://api.github.com/repos/Toflar/api-platform-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Toflar/api-platform-core/downloads","issues_url":"https://api.github.com/repos/Toflar/api-platform-core/issues{/number}","pulls_url":"https://api.github.com/repos/Toflar/api-platform-core/pulls{/number}","milestones_url":"https://api.github.com/repos/Toflar/api-platform-core/milestones{/number}","notifications_url":"https://api.github.com/repos/Toflar/api-platform-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Toflar/api-platform-core/labels{/name}","releases_url":"https://api.github.com/repos/Toflar/api-platform-core/releases{/id}","deployments_url":"https://api.github.com/repos/Toflar/api-platform-core/deployments","created_at":"2017-11-06T17:15:30Z","updated_at":"2017-11-06T17:16:30Z","pushed_at":"2018-05-09T13:49:00Z","git_url":"git://github.com/Toflar/api-platform-core.git","ssh_url":"git@github.com:Toflar/api-platform-core.git","clone_url":"https://github.com/Toflar/api-platform-core.git","svn_url":"https://github.com/Toflar/api-platform-core","homepage":"https://api-platform.com","size":8264,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"api-platform:2.2","ref":"2.2","sha":"29aa05318811e463111f83438cf9ce53eb82191d","user":{"login":"api-platform","id":13420081,"avatar_url":"https://avatars3.githubusercontent.com/u/13420081?v=4","gravatar_id":"","url":"https://api.github.com/users/api-platform","html_url":"https://github.com/api-platform","followers_url":"https://api.github.com/users/api-platform/followers","following_url":"https://api.github.com/users/api-platform/following{/other_user}","gists_url":"https://api.github.com/users/api-platform/gists{/gist_id}","starred_url":"https://api.github.com/users/api-platform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/api-platform/subscriptions","organizations_url":"https://api.github.com/users/api-platform/orgs","repos_url":"https://api.github.com/users/api-platform/repos","events_url":"https://api.github.com/users/api-platform/events{/privacy}","received_events_url":"https://api.github.com/users/api-platform/received_events","type":"Organization","site_admin":false},"repo":{"id":29501260,"name":"core","full_name":"api-platform/core","owner":{"login":"api-platform","id":13420081,"avatar_url":"https://avatars3.githubusercontent.com/u/13420081?v=4","gravatar_id":"","url":"https://api.github.com/users/api-platform","html_url":"https://github.com/api-platform","followers_url":"https://api.github.com/users/api-platform/followers","following_url":"https://api.github.com/users/api-platform/following{/other_user}","gists_url":"https://api.github.com/users/api-platform/gists{/gist_id}","starred_url":"https://api.github.com/users/api-platform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/api-platform/subscriptions","organizations_url":"https://api.github.com/users/api-platform/orgs","repos_url":"https://api.github.com/users/api-platform/repos","events_url":"https://api.github.com/users/api-platform/events{/privacy}","received_events_url":"https://api.github.com/users/api-platform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/api-platform/core","description":"The server component of API Platform: hypermedia and GraphQL APIs in minutes","fork":false,"url":"https://api.github.com/repos/api-platform/core","forks_url":"https://api.github.com/repos/api-platform/core/forks","keys_url":"https://api.github.com/repos/api-platform/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/api-platform/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/api-platform/core/teams","hooks_url":"https://api.github.com/repos/api-platform/core/hooks","issue_events_url":"https://api.github.com/repos/api-platform/core/issues/events{/number}","events_url":"https://api.github.com/repos/api-platform/core/events","assignees_url":"https://api.github.com/repos/api-platform/core/assignees{/user}","branches_url":"https://api.github.com/repos/api-platform/core/branches{/branch}","tags_url":"https://api.github.com/repos/api-platform/core/tags","blobs_url":"https://api.github.com/repos/api-platform/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/api-platform/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/api-platform/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/api-platform/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/api-platform/core/statuses/{sha}","languages_url":"https://api.github.com/repos/api-platform/core/languages","stargazers_url":"https://api.github.com/repos/api-platform/core/stargazers","contributors_url":"https://api.github.com/repos/api-platform/core/contributors","subscribers_url":"https://api.github.com/repos/api-platform/core/subscribers","subscription_url":"https://api.github.com/repos/api-platform/core/subscription","commits_url":"https://api.github.com/repos/api-platform/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/api-platform/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/api-platform/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/api-platform/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/api-platform/core/contents/{+path}","compare_url":"https://api.github.com/repos/api-platform/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/api-platform/core/merges","archive_url":"https://api.github.com/repos/api-platform/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/api-platform/core/downloads","issues_url":"https://api.github.com/repos/api-platform/core/issues{/number}","pulls_url":"https://api.github.com/repos/api-platform/core/pulls{/number}","milestones_url":"https://api.github.com/repos/api-platform/core/milestones{/number}","notifications_url":"https://api.github.com/repos/api-platform/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/api-platform/core/labels{/name}","releases_url":"https://api.github.com/repos/api-platform/core/releases{/id}","deployments_url":"https://api.github.com/repos/api-platform/core/deployments","created_at":"2015-01-19T23:05:56Z","updated_at":"2018-05-08T08:52:33Z","pushed_at":"2018-05-09T13:53:49Z","git_url":"git://github.com/api-platform/core.git","ssh_url":"git@github.com:api-platform/core.git","clone_url":"https://github.com/api-platform/core.git","svn_url":"https://github.com/api-platform/core","homepage":"https://api-platform.com","size":8063,"stargazers_count":695,"watchers_count":695,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":230,"mirror_url":null,"archived":false,"open_issues_count":169,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":230,"open_issues":169,"watchers":695,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/api-platform/core/pulls/1939"},"html":{"href":"https://github.com/api-platform/core/pull/1939"},"issue":{"href":"https://api.github.com/repos/api-platform/core/issues/1939"},"comments":{"href":"https://api.github.com/repos/api-platform/core/issues/1939/comments"},"review_comments":{"href":"https://api.github.com/repos/api-platform/core/pulls/1939/comments"},"review_comment":{"href":"https://api.github.com/repos/api-platform/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/api-platform/core/pulls/1939/commits"},"statuses":{"href":"https://api.github.com/repos/api-platform/core/statuses/6f0063ec52962cf2a173e5dc321c8a4abd7225ae"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Toflar"}}