{"action":"created","comment":{"url":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/comments/232756017","pull_request_review_id":174023586,"id":232756017,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjc1NjAxNw==","diff_hunk":"@@ -96,7 +97,13 @@ public function prepareInsertData($document)\n \n         // add discriminator if the class has one\n         if (isset($class->discriminatorField)) {\n-            $insertData[$class->discriminatorField] = $class->discriminatorValue ?? $class->name;\n+            if ($class->discriminatorValue === null) {","path":"lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php","position":13,"original_position":13,"commit_id":"d89617fc824c835e7b92e30788840d84e1a5d110","original_commit_id":"d89617fc824c835e7b92e30788840d84e1a5d110","user":{"login":"watari","id":35221762,"node_id":"MDQ6VXNlcjM1MjIxNzYy","avatar_url":"https://avatars0.githubusercontent.com/u/35221762?v=4","gravatar_id":"","url":"https://api.github.com/users/watari","html_url":"https://github.com/watari","followers_url":"https://api.github.com/users/watari/followers","following_url":"https://api.github.com/users/watari/following{/other_user}","gists_url":"https://api.github.com/users/watari/gists{/gist_id}","starred_url":"https://api.github.com/users/watari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watari/subscriptions","organizations_url":"https://api.github.com/users/watari/orgs","repos_url":"https://api.github.com/users/watari/repos","events_url":"https://api.github.com/users/watari/events{/privacy}","received_events_url":"https://api.github.com/users/watari/received_events","type":"User","site_admin":false},"body":"Before my changes there was next line:\r\n`$insertData[$class->discriminatorField] = $class->discriminatorValue ?? $class->name;`\r\nSo here was cases when discriminator value can become empty and instead of it name of the class was used. I only added checks here.\r\nIf I comment this out I get next tests failing:\r\n\r\n1. [`Doctrine\\ODM\\MongoDB\\Tests\\GH788Test::testDocumentWithDiscriminatorMap`](https://github.com/doctrine/mongodb-odm/blob/master/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH788Test.php#L13) (one of the documents is unregistered in discriminator map);\r\n2. [`Doctrine\\ODM\\MongoDB\\Tests\\GH788Test::testRefManyWithNoTargetAndExternalDiscriminatorMap`](https://github.com/doctrine/mongodb-odm/blob/master/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH788Test.php#L231) (same case);\r\n3. [`Doctrine\\ODM\\MongoDB\\Tests\\GH788Test::testRefOneWithNoTargetAndExternalDiscriminatorMap`](https://github.com/doctrine/mongodb-odm/blob/master/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH788Test.php#L297) (same case);\r\n4. [`Doctrine\\ODM\\MongoDB\\Tests\\Functional\\Ticket\\GH942Test::testDiscriminatorValueUsesClassNameIfNotInMap`](https://github.com/doctrine/mongodb-odm/blob/master/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH942Test.php#L29) (again same case).\r\nSo exception in this block is triggered when class is not registered is discriminator map that is assigned to class itself. Classname as discriminator value assignment (line 104) is used by [`\\Doctrine\\ODM\\MongoDB\\Tests\\Functional\\Ticket\\GH942Test::testDiscriminatorValueUsesClassNameIfMapIsNotDefined`](https://github.com/doctrine/mongodb-odm/blob/master/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH942Test.php#L13)\r\n","created_at":"2018-11-12T17:55:14Z","updated_at":"2018-11-12T17:55:14Z","html_url":"https://github.com/doctrine/mongodb-odm/pull/1887#discussion_r232756017","pull_request_url":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/1887","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/comments/232756017"},"html":{"href":"https://github.com/doctrine/mongodb-odm/pull/1887#discussion_r232756017"},"pull_request":{"href":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/1887"}},"in_reply_to_id":232550989},"pull_request":{"url":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/1887","id":227032998,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI3MDMyOTk4","html_url":"https://github.com/doctrine/mongodb-odm/pull/1887","diff_url":"https://github.com/doctrine/mongodb-odm/pull/1887.diff","patch_url":"https://github.com/doctrine/mongodb-odm/pull/1887.patch","issue_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1887","number":1887,"state":"open","locked":false,"title":"Exception when persisting class unlisted in disciminator map (Issue 867)","user":{"login":"watari","id":35221762,"node_id":"MDQ6VXNlcjM1MjIxNzYy","avatar_url":"https://avatars0.githubusercontent.com/u/35221762?v=4","gravatar_id":"","url":"https://api.github.com/users/watari","html_url":"https://github.com/watari","followers_url":"https://api.github.com/users/watari/followers","following_url":"https://api.github.com/users/watari/following{/other_user}","gists_url":"https://api.github.com/users/watari/gists{/gist_id}","starred_url":"https://api.github.com/users/watari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watari/subscriptions","organizations_url":"https://api.github.com/users/watari/orgs","repos_url":"https://api.github.com/users/watari/repos","events_url":"https://api.github.com/users/watari/events{/privacy}","received_events_url":"https://api.github.com/users/watari/received_events","type":"User","site_admin":false},"body":"\r\n<!-- Fill in the relevant information below to help triage your pull request. -->\r\n\r\n|      Q       |   A\r\n|------------- | -----------\r\n| Type         | feature/improvement\r\n| BC Break     | yes\r\n| Fixed issues | https://github.com/doctrine/mongodb-odm/issues/867\r\n\r\n#### Summary\r\nUpdated persisting logic to throw exception of class is not listed in discriminator map.\r\n\r\nThere is no new tests is added since library have a set of old tests that is cover most of the cases.\r\n\r\nRight now exception message contain information only about unlisted class without parent class since in the places of the checks I don't find a way of extracting parent class info.\r\n","created_at":"2018-10-30T18:25:24Z","updated_at":"2018-11-12T17:55:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eb7832bffbb4e3e90ddfbea249c511777cc1b6d2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/1887/commits","review_comments_url":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/1887/comments","review_comment_url":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1887/comments","statuses_url":"https://api.github.com/repos/doctrine/mongodb-odm/statuses/d89617fc824c835e7b92e30788840d84e1a5d110","head":{"label":"watari:issue_867","ref":"issue_867","sha":"d89617fc824c835e7b92e30788840d84e1a5d110","user":{"login":"watari","id":35221762,"node_id":"MDQ6VXNlcjM1MjIxNzYy","avatar_url":"https://avatars0.githubusercontent.com/u/35221762?v=4","gravatar_id":"","url":"https://api.github.com/users/watari","html_url":"https://github.com/watari","followers_url":"https://api.github.com/users/watari/followers","following_url":"https://api.github.com/users/watari/following{/other_user}","gists_url":"https://api.github.com/users/watari/gists{/gist_id}","starred_url":"https://api.github.com/users/watari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watari/subscriptions","organizations_url":"https://api.github.com/users/watari/orgs","repos_url":"https://api.github.com/users/watari/repos","events_url":"https://api.github.com/users/watari/events{/privacy}","received_events_url":"https://api.github.com/users/watari/received_events","type":"User","site_admin":false},"repo":{"id":153771868,"node_id":"MDEwOlJlcG9zaXRvcnkxNTM3NzE4Njg=","name":"mongodb-odm","full_name":"watari/mongodb-odm","private":false,"owner":{"login":"watari","id":35221762,"node_id":"MDQ6VXNlcjM1MjIxNzYy","avatar_url":"https://avatars0.githubusercontent.com/u/35221762?v=4","gravatar_id":"","url":"https://api.github.com/users/watari","html_url":"https://github.com/watari","followers_url":"https://api.github.com/users/watari/followers","following_url":"https://api.github.com/users/watari/following{/other_user}","gists_url":"https://api.github.com/users/watari/gists{/gist_id}","starred_url":"https://api.github.com/users/watari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watari/subscriptions","organizations_url":"https://api.github.com/users/watari/orgs","repos_url":"https://api.github.com/users/watari/repos","events_url":"https://api.github.com/users/watari/events{/privacy}","received_events_url":"https://api.github.com/users/watari/received_events","type":"User","site_admin":false},"html_url":"https://github.com/watari/mongodb-odm","description":"Doctrine MongoDB Object Document Mapper (ODM)","fork":true,"url":"https://api.github.com/repos/watari/mongodb-odm","forks_url":"https://api.github.com/repos/watari/mongodb-odm/forks","keys_url":"https://api.github.com/repos/watari/mongodb-odm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/watari/mongodb-odm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/watari/mongodb-odm/teams","hooks_url":"https://api.github.com/repos/watari/mongodb-odm/hooks","issue_events_url":"https://api.github.com/repos/watari/mongodb-odm/issues/events{/number}","events_url":"https://api.github.com/repos/watari/mongodb-odm/events","assignees_url":"https://api.github.com/repos/watari/mongodb-odm/assignees{/user}","branches_url":"https://api.github.com/repos/watari/mongodb-odm/branches{/branch}","tags_url":"https://api.github.com/repos/watari/mongodb-odm/tags","blobs_url":"https://api.github.com/repos/watari/mongodb-odm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/watari/mongodb-odm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/watari/mongodb-odm/git/refs{/sha}","trees_url":"https://api.github.com/repos/watari/mongodb-odm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/watari/mongodb-odm/statuses/{sha}","languages_url":"https://api.github.com/repos/watari/mongodb-odm/languages","stargazers_url":"https://api.github.com/repos/watari/mongodb-odm/stargazers","contributors_url":"https://api.github.com/repos/watari/mongodb-odm/contributors","subscribers_url":"https://api.github.com/repos/watari/mongodb-odm/subscribers","subscription_url":"https://api.github.com/repos/watari/mongodb-odm/subscription","commits_url":"https://api.github.com/repos/watari/mongodb-odm/commits{/sha}","git_commits_url":"https://api.github.com/repos/watari/mongodb-odm/git/commits{/sha}","comments_url":"https://api.github.com/repos/watari/mongodb-odm/comments{/number}","issue_comment_url":"https://api.github.com/repos/watari/mongodb-odm/issues/comments{/number}","contents_url":"https://api.github.com/repos/watari/mongodb-odm/contents/{+path}","compare_url":"https://api.github.com/repos/watari/mongodb-odm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/watari/mongodb-odm/merges","archive_url":"https://api.github.com/repos/watari/mongodb-odm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/watari/mongodb-odm/downloads","issues_url":"https://api.github.com/repos/watari/mongodb-odm/issues{/number}","pulls_url":"https://api.github.com/repos/watari/mongodb-odm/pulls{/number}","milestones_url":"https://api.github.com/repos/watari/mongodb-odm/milestones{/number}","notifications_url":"https://api.github.com/repos/watari/mongodb-odm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/watari/mongodb-odm/labels{/name}","releases_url":"https://api.github.com/repos/watari/mongodb-odm/releases{/id}","deployments_url":"https://api.github.com/repos/watari/mongodb-odm/deployments","created_at":"2018-10-19T11:20:54Z","updated_at":"2018-10-26T10:25:46Z","pushed_at":"2018-11-09T06:01:51Z","git_url":"git://github.com/watari/mongodb-odm.git","ssh_url":"git@github.com:watari/mongodb-odm.git","clone_url":"https://github.com/watari/mongodb-odm.git","svn_url":"https://github.com/watari/mongodb-odm","homepage":"https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/","size":8103,"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","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"doctrine:master","ref":"master","sha":"4b59521bb4a16031b8b024008d88e118fc5cc5ec","user":{"login":"doctrine","id":209254,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwOTI1NA==","avatar_url":"https://avatars3.githubusercontent.com/u/209254?v=4","gravatar_id":"","url":"https://api.github.com/users/doctrine","html_url":"https://github.com/doctrine","followers_url":"https://api.github.com/users/doctrine/followers","following_url":"https://api.github.com/users/doctrine/following{/other_user}","gists_url":"https://api.github.com/users/doctrine/gists{/gist_id}","starred_url":"https://api.github.com/users/doctrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctrine/subscriptions","organizations_url":"https://api.github.com/users/doctrine/orgs","repos_url":"https://api.github.com/users/doctrine/repos","events_url":"https://api.github.com/users/doctrine/events{/privacy}","received_events_url":"https://api.github.com/users/doctrine/received_events","type":"Organization","site_admin":false},"repo":{"id":677781,"node_id":"MDEwOlJlcG9zaXRvcnk2Nzc3ODE=","name":"mongodb-odm","full_name":"doctrine/mongodb-odm","private":false,"owner":{"login":"doctrine","id":209254,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwOTI1NA==","avatar_url":"https://avatars3.githubusercontent.com/u/209254?v=4","gravatar_id":"","url":"https://api.github.com/users/doctrine","html_url":"https://github.com/doctrine","followers_url":"https://api.github.com/users/doctrine/followers","following_url":"https://api.github.com/users/doctrine/following{/other_user}","gists_url":"https://api.github.com/users/doctrine/gists{/gist_id}","starred_url":"https://api.github.com/users/doctrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctrine/subscriptions","organizations_url":"https://api.github.com/users/doctrine/orgs","repos_url":"https://api.github.com/users/doctrine/repos","events_url":"https://api.github.com/users/doctrine/events{/privacy}","received_events_url":"https://api.github.com/users/doctrine/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/doctrine/mongodb-odm","description":"Doctrine MongoDB Object Document Mapper (ODM)","fork":false,"url":"https://api.github.com/repos/doctrine/mongodb-odm","forks_url":"https://api.github.com/repos/doctrine/mongodb-odm/forks","keys_url":"https://api.github.com/repos/doctrine/mongodb-odm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/doctrine/mongodb-odm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/doctrine/mongodb-odm/teams","hooks_url":"https://api.github.com/repos/doctrine/mongodb-odm/hooks","issue_events_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/events{/number}","events_url":"https://api.github.com/repos/doctrine/mongodb-odm/events","assignees_url":"https://api.github.com/repos/doctrine/mongodb-odm/assignees{/user}","branches_url":"https://api.github.com/repos/doctrine/mongodb-odm/branches{/branch}","tags_url":"https://api.github.com/repos/doctrine/mongodb-odm/tags","blobs_url":"https://api.github.com/repos/doctrine/mongodb-odm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/doctrine/mongodb-odm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/doctrine/mongodb-odm/git/refs{/sha}","trees_url":"https://api.github.com/repos/doctrine/mongodb-odm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/doctrine/mongodb-odm/statuses/{sha}","languages_url":"https://api.github.com/repos/doctrine/mongodb-odm/languages","stargazers_url":"https://api.github.com/repos/doctrine/mongodb-odm/stargazers","contributors_url":"https://api.github.com/repos/doctrine/mongodb-odm/contributors","subscribers_url":"https://api.github.com/repos/doctrine/mongodb-odm/subscribers","subscription_url":"https://api.github.com/repos/doctrine/mongodb-odm/subscription","commits_url":"https://api.github.com/repos/doctrine/mongodb-odm/commits{/sha}","git_commits_url":"https://api.github.com/repos/doctrine/mongodb-odm/git/commits{/sha}","comments_url":"https://api.github.com/repos/doctrine/mongodb-odm/comments{/number}","issue_comment_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/comments{/number}","contents_url":"https://api.github.com/repos/doctrine/mongodb-odm/contents/{+path}","compare_url":"https://api.github.com/repos/doctrine/mongodb-odm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/doctrine/mongodb-odm/merges","archive_url":"https://api.github.com/repos/doctrine/mongodb-odm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/doctrine/mongodb-odm/downloads","issues_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues{/number}","pulls_url":"https://api.github.com/repos/doctrine/mongodb-odm/pulls{/number}","milestones_url":"https://api.github.com/repos/doctrine/mongodb-odm/milestones{/number}","notifications_url":"https://api.github.com/repos/doctrine/mongodb-odm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/doctrine/mongodb-odm/labels{/name}","releases_url":"https://api.github.com/repos/doctrine/mongodb-odm/releases{/id}","deployments_url":"https://api.github.com/repos/doctrine/mongodb-odm/deployments","created_at":"2010-05-20T20:20:00Z","updated_at":"2018-11-12T08:57:49Z","pushed_at":"2018-11-12T06:44:57Z","git_url":"git://github.com/doctrine/mongodb-odm.git","ssh_url":"git@github.com:doctrine/mongodb-odm.git","clone_url":"https://github.com/doctrine/mongodb-odm.git","svn_url":"https://github.com/doctrine/mongodb-odm","homepage":"https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/","size":8089,"stargazers_count":824,"watchers_count":824,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":421,"mirror_url":null,"archived":false,"open_issues_count":120,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":421,"open_issues":120,"watchers":824,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/1887"},"html":{"href":"https://github.com/doctrine/mongodb-odm/pull/1887"},"issue":{"href":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1887"},"comments":{"href":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1887/comments"},"review_comments":{"href":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/1887/comments"},"review_comment":{"href":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/doctrine/mongodb-odm/pulls/1887/commits"},"statuses":{"href":"https://api.github.com/repos/doctrine/mongodb-odm/statuses/d89617fc824c835e7b92e30788840d84e1a5d110"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"watari"}}