{"id":1680,"date":"2022-08-30T15:18:33","date_gmt":"2022-08-30T15:18:33","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/27\/doctrine-issue-unable-to-persist-entity-if-adding-items-to-a-relation-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:18:33","modified_gmt":"2022-08-30T15:18:33","slug":"doctrine-issue-unable-to-persist-entity-if-adding-items-to-a-relation-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/doctrine-issue-unable-to-persist-entity-if-adding-items-to-a-relation-collection-of-common-programming-errors\/","title":{"rendered":"Doctrine Issue; Unable to persist entity if adding items to a relation-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m having some difficulty setting up Doctrine and am hoping some guru&#8217;s can give me a hand. If I try to save a MainEntity on its own, it works fine. However, if I add a &#8220;tag&#8221; to the tags collection of this entity, I get an error.<\/p>\n<p>Here is my info: I have entities that are similar to this<\/p>\n<pre><code>namespace CG;\nclass Content\n{\n    public $id;\n    public $tags;\n    public function __construct()\n    {\n        $this-&gt;tags = new ArrayCollection();\n    } \n}\n\n\/* this is single table inheritance *\/\nclass Tag extends TagAssociation\n{\n    public $id;\n    public $term;\n    public $content;\n}\n\nclass Term\n{\n    public $id;\n    public $name;\n}\n<\/code><\/pre>\n<p>Mapping<\/p>\n<pre><code>\n\n      \n          \n              \n          \n            \n                 \n                \n                    \n                \n            \n \n\n\n      \n            \n            \n                \n            \n      \n\n\n\n\n      \n          \n              \n          \n\n          \n      \n \n\n\n\n      \n             \n             \n                  \n              \n\n            \n            \n                \n                \n            \n\n\n            \n                \n            \n\n\n            \n                \n                \n                    \n                \n            \n      \n\n<\/code><\/pre>\n<p>finally, here are the errors I am getting<\/p>\n<pre><code>( ! ) Warning: spl_object_hash() expects parameter 1 to be object, array given in C:\\wamp\\www\\Content\\Doctrine\\ORM\\UnitOfWork.php on line 1073\nCall Stack\n#   Time    Memory  Function    Location\n1   0.0130  437368  {main}( )   ..\\index.php:0\n2   0.3809  3813352 CG\\handleRequest( ) ..\\index.php:181\n3   0.3817  3813384 CG\\saveContent( )   ..\\index.php:92\n4   0.4617  6772280 CG\\Database-&gt;saveContent( ) ..\\index.php:33\n5   0.4623  6772872 Doctrine\\ORM\\EntityManager-&gt;flush( )    ..\\Database.php:120\n6   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;commit( )  ..\\EntityManager.php:334\n7   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSets( )   ..\\UnitOfWork.php:256\n8   0.4669  6932368 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSet( )    ..\\UnitOfWork.php:510\n9   0.4671  6934472 Doctrine\\ORM\\UnitOfWork-&gt;computeAssociationChanges( )   ..\\UnitOfWork.php:495\n10  0.4672  6934672 Doctrine\\ORM\\UnitOfWork-&gt;getEntityState( )  ..\\UnitOfWork.php:572\n11  0.4672  6934704 spl_object_hash ( ) ..\\UnitOfWork.php:1073\n\n( ! ) Warning: spl_object_hash() expects parameter 1 to be object, array given in C:\\wamp\\www\\Content\\Doctrine\\ORM\\UnitOfWork.php on line 573\nCall Stack\n#   Time    Memory  Function    Location\n1   0.0130  437368  {main}( )   ..\\index.php:0\n2   0.3809  3813352 CG\\handleRequest( ) ..\\index.php:181\n3   0.3817  3813384 CG\\saveContent( )   ..\\index.php:92\n4   0.4617  6772280 CG\\Database-&gt;saveContent( ) ..\\index.php:33\n5   0.4623  6772872 Doctrine\\ORM\\EntityManager-&gt;flush( )    ..\\Database.php:120\n6   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;commit( )  ..\\EntityManager.php:334\n7   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSets( )   ..\\UnitOfWork.php:256\n8   0.4669  6932368 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSet( )    ..\\UnitOfWork.php:510\n9   0.4671  6934472 Doctrine\\ORM\\UnitOfWork-&gt;computeAssociationChanges( )   ..\\UnitOfWork.php:495\n10  0.4677  6934704 spl_object_hash ( ) ..\\UnitOfWork.php:573\n\n( ! ) Warning: spl_object_hash() expects parameter 1 to be object, array given in C:\\wamp\\www\\Content\\Doctrine\\ORM\\UnitOfWork.php on line 601\nCall Stack\n#   Time    Memory  Function    Location\n1   0.0130  437368  {main}( )   ..\\index.php:0\n2   0.3809  3813352 CG\\handleRequest( ) ..\\index.php:181\n3   0.3817  3813384 CG\\saveContent( )   ..\\index.php:92\n4   0.4617  6772280 CG\\Database-&gt;saveContent( ) ..\\index.php:33\n5   0.4623  6772872 Doctrine\\ORM\\EntityManager-&gt;flush( )    ..\\Database.php:120\n6   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;commit( )  ..\\EntityManager.php:334\n7   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSets( )   ..\\UnitOfWork.php:256\n8   0.4669  6932368 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSet( )    ..\\UnitOfWork.php:510\n9   0.4671  6934472 Doctrine\\ORM\\UnitOfWork-&gt;computeAssociationChanges( )   ..\\UnitOfWork.php:495\n10  0.4680  6934704 Doctrine\\ORM\\UnitOfWork-&gt;persistNew( )  ..\\UnitOfWork.php:583\n11  0.4680  6934736 spl_object_hash ( ) ..\\UnitOfWork.php:601\n\n( ! ) Warning: spl_object_hash() expects parameter 1 to be object, array given in C:\\wamp\\www\\Content\\Doctrine\\ORM\\UnitOfWork.php on line 882\nCall Stack\n#   Time    Memory  Function    Location\n1   0.0130  437368  {main}( )   ..\\index.php:0\n2   0.3809  3813352 CG\\handleRequest( ) ..\\index.php:181\n3   0.3817  3813384 CG\\saveContent( )   ..\\index.php:92\n4   0.4617  6772280 CG\\Database-&gt;saveContent( ) ..\\index.php:33\n5   0.4623  6772872 Doctrine\\ORM\\EntityManager-&gt;flush( )    ..\\Database.php:120\n6   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;commit( )  ..\\EntityManager.php:334\n7   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSets( )   ..\\UnitOfWork.php:256\n8   0.4669  6932368 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSet( )    ..\\UnitOfWork.php:510\n9   0.4671  6934472 Doctrine\\ORM\\UnitOfWork-&gt;computeAssociationChanges( )   ..\\UnitOfWork.php:495\n10  0.4680  6934704 Doctrine\\ORM\\UnitOfWork-&gt;persistNew( )  ..\\UnitOfWork.php:583\n11  0.4685  6934816 Doctrine\\ORM\\UnitOfWork-&gt;scheduleForInsert( )   ..\\UnitOfWork.php:621\n12  0.4685  6934848 spl_object_hash ( ) ..\\UnitOfWork.php:882\n\n( ! ) Warning: spl_object_hash() expects parameter 1 to be object, array given in C:\\wamp\\www\\Content\\Doctrine\\ORM\\UnitOfWork.php on line 405\nCall Stack\n#   Time    Memory  Function    Location\n1   0.0130  437368  {main}( )   ..\\index.php:0\n2   0.3809  3813352 CG\\handleRequest( ) ..\\index.php:181\n3   0.3817  3813384 CG\\saveContent( )   ..\\index.php:92\n4   0.4617  6772280 CG\\Database-&gt;saveContent( ) ..\\index.php:33\n5   0.4623  6772872 Doctrine\\ORM\\EntityManager-&gt;flush( )    ..\\Database.php:120\n6   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;commit( )  ..\\EntityManager.php:334\n7   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSets( )   ..\\UnitOfWork.php:256\n8   0.4669  6932368 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSet( )    ..\\UnitOfWork.php:510\n9   0.4671  6934472 Doctrine\\ORM\\UnitOfWork-&gt;computeAssociationChanges( )   ..\\UnitOfWork.php:495\n10  0.4689  6935112 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSet( )    ..\\UnitOfWork.php:584\n11  0.4689  6935144 spl_object_hash ( ) ..\\UnitOfWork.php:405\n\n( ! ) Warning: ReflectionProperty::getValue() expects parameter 1 to be object, array given in C:\\wamp\\www\\Content\\Doctrine\\ORM\\UnitOfWork.php on line 408\nCall Stack\n#   Time    Memory  Function    Location\n1   0.0130  437368  {main}( )   ..\\index.php:0\n2   0.3809  3813352 CG\\handleRequest( ) ..\\index.php:181\n3   0.3817  3813384 CG\\saveContent( )   ..\\index.php:92\n4   0.4617  6772280 CG\\Database-&gt;saveContent( ) ..\\index.php:33\n5   0.4623  6772872 Doctrine\\ORM\\EntityManager-&gt;flush( )    ..\\Database.php:120\n6   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;commit( )  ..\\EntityManager.php:334\n7   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSets( )   ..\\UnitOfWork.php:256\n8   0.4669  6932368 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSet( )    ..\\UnitOfWork.php:510\n9   0.4671  6934472 Doctrine\\ORM\\UnitOfWork-&gt;computeAssociationChanges( )   ..\\UnitOfWork.php:495\n10  0.4689  6935112 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSet( )    ..\\UnitOfWork.php:584\n11  0.4693  6935344 ReflectionProperty-&gt;getValue( ) ..\\UnitOfWork.php:408\n\n( ! ) Warning: ReflectionProperty::getValue() expects parameter 1 to be object, array given in C:\\wamp\\www\\Content\\Doctrine\\ORM\\UnitOfWork.php on line 408\nCall Stack\n#   Time    Memory  Function    Location\n1   0.0130  437368  {main}( )   ..\\index.php:0\n2   0.3809  3813352 CG\\handleRequest( ) ..\\index.php:181\n3   0.3817  3813384 CG\\saveContent( )   ..\\index.php:92\n4   0.4617  6772280 CG\\Database-&gt;saveContent( ) ..\\index.php:33\n5   0.4623  6772872 Doctrine\\ORM\\EntityManager-&gt;flush( )    ..\\Database.php:120\n6   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;commit( )  ..\\EntityManager.php:334\n7   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSets( )   ..\\UnitOfWork.php:256\n8   0.4669  6932368 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSet( )    ..\\UnitOfWork.php:510\n9   0.4671  6934472 Doctrine\\ORM\\UnitOfWork-&gt;computeAssociationChanges( )   ..\\UnitOfWork.php:495\n10  0.4689  6935112 Doctrine\\ORM\\UnitOfWork-&gt;computeChangeSet( )    ..\\UnitOfWork.php:584\n11  0.4696  6935424 ReflectionProperty-&gt;getValue( ) ..\\UnitOfWork.php:408\n\n( ! ) Warning: get_class() expects parameter 1 to be object, array given in C:\\wamp\\www\\Content\\Doctrine\\ORM\\UnitOfWork.php on line 839\nCall Stack\n#   Time    Memory  Function    Location\n1   0.0130  437368  {main}( )   ..\\index.php:0\n2   0.3809  3813352 CG\\handleRequest( ) ..\\index.php:181\n3   0.3817  3813384 CG\\saveContent( )   ..\\index.php:92\n4   0.4617  6772280 CG\\Database-&gt;saveContent( ) ..\\index.php:33\n5   0.4623  6772872 Doctrine\\ORM\\EntityManager-&gt;flush( )    ..\\Database.php:120\n6   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;commit( )  ..\\EntityManager.php:334\n7   0.4703  6935072 Doctrine\\ORM\\UnitOfWork-&gt;getCommitOrder( )  ..\\UnitOfWork.php:279\n8   0.4712  6960832 get_class ( )   ..\\UnitOfWork.php:839\n\n( ! ) Warning: class_parents() [function.class-parents]: object or string expected in C:\\wamp\\www\\Content\\Doctrine\\ORM\\Mapping\\ClassMetadataFactory.php on line 223\nCall Stack\n#   Time    Memory  Function    Location\n1   0.0130  437368  {main}( )   ..\\index.php:0\n2   0.3809  3813352 CG\\handleRequest( ) ..\\index.php:181\n3   0.3817  3813384 CG\\saveContent( )   ..\\index.php:92\n4   0.4617  6772280 CG\\Database-&gt;saveContent( ) ..\\index.php:33\n5   0.4623  6772872 Doctrine\\ORM\\EntityManager-&gt;flush( )    ..\\Database.php:120\n6   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;commit( )  ..\\EntityManager.php:334\n7   0.4703  6935072 Doctrine\\ORM\\UnitOfWork-&gt;getCommitOrder( )  ..\\UnitOfWork.php:279\n8   0.4715  6960784 Doctrine\\ORM\\EntityManager-&gt;getClassMetadata( ) ..\\UnitOfWork.php:841\n9   0.4715  6960784 Doctrine\\ORM\\Mapping\\ClassMetadataFactory-&gt;getMetadataFor( )    ..\\EntityManager.php:257\n10  0.4716  6960816 Doctrine\\ORM\\Mapping\\ClassMetadataFactory-&gt;loadMetadata( )  ..\\ClassMetadataFactory.php:170\n11  0.4716  6960936 Doctrine\\ORM\\Mapping\\ClassMetadataFactory-&gt;getParentClasses( )  ..\\ClassMetadataFactory.php:246\n12  0.4716  6961088 class_parents ( )   ..\\ClassMetadataFactory.php:223\n\n( ! ) Warning: array_reverse() expects parameter 1 to be array, boolean given in C:\\wamp\\www\\Content\\Doctrine\\ORM\\Mapping\\ClassMetadataFactory.php on line 223\nCall Stack\n#   Time    Memory  Function    Location\n1   0.0130  437368  {main}( )   ..\\index.php:0\n2   0.3809  3813352 CG\\handleRequest( ) ..\\index.php:181\n3   0.3817  3813384 CG\\saveContent( )   ..\\index.php:92\n4   0.4617  6772280 CG\\Database-&gt;saveContent( ) ..\\index.php:33\n5   0.4623  6772872 Doctrine\\ORM\\EntityManager-&gt;flush( )    ..\\Database.php:120\n6   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;commit( )  ..\\EntityManager.php:334\n7   0.4703  6935072 Doctrine\\ORM\\UnitOfWork-&gt;getCommitOrder( )  ..\\UnitOfWork.php:279\n8   0.4715  6960784 Doctrine\\ORM\\EntityManager-&gt;getClassMetadata( ) ..\\UnitOfWork.php:841\n9   0.4715  6960784 Doctrine\\ORM\\Mapping\\ClassMetadataFactory-&gt;getMetadataFor( )    ..\\EntityManager.php:257\n10  0.4716  6960816 Doctrine\\ORM\\Mapping\\ClassMetadataFactory-&gt;loadMetadata( )  ..\\ClassMetadataFactory.php:170\n11  0.4716  6960936 Doctrine\\ORM\\Mapping\\ClassMetadataFactory-&gt;getParentClasses( )  ..\\ClassMetadataFactory.php:246\n12  0.4720  6961448 array_reverse ( )   ..\\ClassMetadataFactory.php:223\n\n( ! ) Warning: Invalid argument supplied for foreach() in C:\\wamp\\www\\Content\\Doctrine\\ORM\\Mapping\\ClassMetadataFactory.php on line 223\nCall Stack\n#   Time    Memory  Function    Location\n1   0.0130  437368  {main}( )   ..\\index.php:0\n2   0.3809  3813352 CG\\handleRequest( ) ..\\index.php:181\n3   0.3817  3813384 CG\\saveContent( )   ..\\index.php:92\n4   0.4617  6772280 CG\\Database-&gt;saveContent( ) ..\\index.php:33\n5   0.4623  6772872 Doctrine\\ORM\\EntityManager-&gt;flush( )    ..\\Database.php:120\n6   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;commit( )  ..\\EntityManager.php:334\n7   0.4703  6935072 Doctrine\\ORM\\UnitOfWork-&gt;getCommitOrder( )  ..\\UnitOfWork.php:279\n8   0.4715  6960784 Doctrine\\ORM\\EntityManager-&gt;getClassMetadata( ) ..\\UnitOfWork.php:841\n9   0.4715  6960784 Doctrine\\ORM\\Mapping\\ClassMetadataFactory-&gt;getMetadataFor( )    ..\\EntityManager.php:257\n10  0.4716  6960816 Doctrine\\ORM\\Mapping\\ClassMetadataFactory-&gt;loadMetadata( )  ..\\ClassMetadataFactory.php:170\n11  0.4716  6960936 Doctrine\\ORM\\Mapping\\ClassMetadataFactory-&gt;getParentClasses( )  ..\\ClassMetadataFactory.php:246\n\n( ! ) Fatal error: Uncaught exception 'ReflectionException' with message 'Class does not exist' in C:\\wamp\\www\\Content\\Doctrine\\ORM\\Mapping\\ClassMetadata.php on line 66\n( ! ) ReflectionException: Class does not exist in C:\\wamp\\www\\Content\\Doctrine\\ORM\\Mapping\\ClassMetadata.php on line 66\nCall Stack\n#   Time    Memory  Function    Location\n1   0.0130  437368  {main}( )   ..\\index.php:0\n2   0.3809  3813352 CG\\handleRequest( ) ..\\index.php:181\n3   0.3817  3813384 CG\\saveContent( )   ..\\index.php:92\n4   0.4617  6772280 CG\\Database-&gt;saveContent( ) ..\\index.php:33\n5   0.4623  6772872 Doctrine\\ORM\\EntityManager-&gt;flush( )    ..\\Database.php:120\n6   0.4623  6772872 Doctrine\\ORM\\UnitOfWork-&gt;commit( )  ..\\EntityManager.php:334\n7   0.4703  6935072 Doctrine\\ORM\\UnitOfWork-&gt;getCommitOrder( )  ..\\UnitOfWork.php:279\n8   0.4715  6960784 Doctrine\\ORM\\EntityManager-&gt;getClassMetadata( ) ..\\UnitOfWork.php:841\n9   0.4715  6960784 Doctrine\\ORM\\Mapping\\ClassMetadataFactory-&gt;getMetadataFor( )    ..\\EntityManager.php:257\n10  0.4716  6960816 Doctrine\\ORM\\Mapping\\ClassMetadataFactory-&gt;loadMetadata( )  ..\\ClassMetadataFactory.php:170\n11  0.4727  6971528 Doctrine\\ORM\\Mapping\\ClassMetadataFactory-&gt;newClassMetadataInstance( )  ..\\ClassMetadataFactory.php:263\n12  0.4728  6973768 Doctrine\\ORM\\Mapping\\ClassMetadata-&gt;__construct( )  ..\\ClassMetadataFactory.php:362\n13  0.4728  6974008 ReflectionClass-&gt;__construct( ) ..\\ClassMetadata.php:66\n<\/code><\/pre>\n<p>Edit 1:<\/p>\n<p>Here are the lines from my SaveContent function<\/p>\n<pre><code>public function saveContent($content)\n    {\n        $this-&gt;entityManager-&gt;persist($content);\n        $this-&gt;entityManager-&gt;flush();\n    }\n<\/code><\/pre>\n<p>Save content is pretty easy, however, to create the $content, I am doing the following<\/p>\n<ol>\n<li>receive json that describes changes to the content object<\/li>\n<li>check if the json I receive has an id. If so, I get the content object from the database. If not, I create a new content object<\/li>\n<li>copy over the fields from the json object to my content object<\/li>\n<li>call $content-&gt;tags-&gt;clear()<\/li>\n<li>loop through each of the tags in the json object. These are just strings. I need to recreate $content-&gt;tags<\/li>\n<li>\n<ol>\n<li>See if there is a tag for this contentId and termName in the database. If so, add it to the tags collection. Done.<\/li>\n<li>If not, see if there is a term in the database that matches the termName. If so, create a new tag, assign the term and content to it, and add it to tags. Done.<\/li>\n<li>if not, create a new tag and a new term, assign the term and content to it, and add it to tags. Done.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>Doing a var dump shows that my $content object is as expected.<\/p>\n<p><strong>Edit 2: Solved<\/strong><\/p>\n<p><strong>My content object wasn&#8217;t as expected after all. I had added an array to the tags collection rather than a CG\\Tag.<\/strong><\/p>\n<ol>\n<li>\n<p>Just answering this question to close it. If anyone else has the same problem, maybe this can help.<\/p>\n<p>My content object wasn&#8217;t as expected after all. I had added an array to the tags collection rather than a CG\\Tag. This resulted in the collection not being what Doctrine had expected hence the warning<\/p>\n<blockquote>\n<p>Warning: spl_object_hash() expects parameter 1 to be object, array given<\/p>\n<\/blockquote>\n<p>The warning was much more informative than the actual error.<\/p>\n<\/li>\n<li>\n<p>Just for practical purposes for Symfony2 developers: Take care to the difference between the <code>addCategory<\/code> method and the <code>setCategory<\/code> method!<\/p>\n<pre><code>\n<\/code><\/pre>\n<\/li>\n<li>\n<p>I had exaclty the same problem &#8211; also with tags (many tags related to many articles in DB).<\/p>\n<p>I had the following instruction:<\/p>\n<pre><code>                    foreach ($tags as $vv) {\n                        $tobj = $this-&gt;getDoctrine()\n                            -&gt;getRepository(\"MainBundle:Tag\")\n                                -&gt;findByTag($vv); \/\/ returns ARRAY of objects (= not wanted and not expected by Doctrine)\n                        \/\/...\n                        $artic-&gt;getTags()-&gt;add($tobj);\n<\/code><\/pre>\n<p>And properly working code is:<\/p>\n<pre><code>                    foreach ($tags as $vv) {\n                        $tobj = $this-&gt;getDoctrine()\n                            -&gt;getRepository(\"MainBundle:Tag\")\n                                -&gt;findOneByTag($vv); \/\/ returns one object\n                        \/\/...\n                        $artic-&gt;getTags()-&gt;add($tobj);\n<\/code><\/pre>\n<p>(notice findONEby, not findby).<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-27 12:27:26. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m having some difficulty setting up Doctrine and am hoping some guru&#8217;s can give me a hand. If I try to save a MainEntity on its own, it works fine. However, if I add a &#8220;tag&#8221; to the tags collection of this entity, I get an error. Here is my info: I have entities that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1680","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1680"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1680\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}