Replies: 8 comments
-
|
I believe this may be a duplicate of #2931? |
Beta Was this translation helpful? Give feedback.
-
In your issue you seem to mention only the missing attributes of the daughter classes whereas in my case it is an impossibility to use Doctrine Relations with an abstract class. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @baudev, as we've discussed on Slack, have you checked this out? (The annotation has the same name as Doctrine's |
Beta Was this translation helpful? Give feedback.
-
|
Hi @teohhanhui, not sure if I should post it here, but since the issue was still open ... 🙂 I'm also getting This is the (simplified) scheme: <entity name="App\Entity\User" inheritance-type="JOINED">
<discriminator-column name="type" type="string"/>
<discriminator-map>
<discriminator-mapping value="type_a" class="App\Entity\UserTypeA"/>
<discriminator-mapping value="type_b" class="App\Entity\UserTypeB"/>
<discriminator-mapping value="type_c" class="App\Entity\UserTypeC"/>
</discriminator-map>
<one-to-many field="documents" target-entity="App\Entity\Document" mapped-by="user" orphan-removal="true"/>
</entity>
<entity name="App\Entity\Document">
<many-to-one field="user" target-entity="App\Entity\User" inversed-by="documents"/>
</entity>Is there anything I should be doing differently starting from 2.4.4? |
Beta Was this translation helpful? Give feedback.
-
|
Hello @baudev, did you ever find a way to fix this? 🙂 |
Beta Was this translation helpful? Give feedback.
-
|
@eekes, unfortunately I haven't really looked yet. I have many other bugs in parallel. |
Beta Was this translation helpful? Give feedback.
-
|
We see the same issue but interestingly only in API tests. It works just fine in the browser with real requests ... 🤔 |
Beta Was this translation helpful? Give feedback.
-
|
@teohhanhui Unfortunately one cannot add the Serializer This makes sense since the property is managed by Doctrine using the Attempt to add it: /**
* @ORM\Column(type="string", length=255)
*/
public string $type;Next error: Any ideas? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The regression appeared in version 2.4.4. Indeed, the code below is fully functional with version 2.4.3. I've discussed with @teohhanhui on Slack about this issue.
On the image, we can see the inheritance relationship between the different objects.
TeachrandClientinherit fromUserwhich is an abstract class (codes are below).There is a relationship between the
UserandAddressobjects.User:Client(same forTeachr):Address:The error:
{ "@context": "/contexts/Error", "@type": "hydra:Error", "hydra:title": "An error occurred", "hydra:description": "Cannot instantiate abstract class App\\Entity\\User", "trace": [ { "namespace": "", "short_class": "", "class": "", "type": "", "function": "", "file": "/var/www/html/vendor/symfony/serializer/Normalizer/AbstractNormalizer.php", "line": 452, "args": [] }, { "namespace": "", "short_class": "ReflectionClass", "class": "ReflectionClass", "type": "->", "function": "newInstanceArgs", "file": "/var/www/html/vendor/symfony/serializer/Normalizer/AbstractNormalizer.php", "line": 452, "args": [ [ "array", [] ] ] }, { "namespace": "Symfony\\Component\\Serializer\\Normalizer", "short_class": "AbstractNormalizer", "class": "Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer", "type": "->", "function": "instantiateObject", "file": "/var/www/html/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php", "line": 182, "args": [ [ "array", [ [ "string", "/clients/1" ] ] ], [ "string", "App\\Entity\\User" ], [ "array", { "groups": [ "array", [ [ "string", "write_address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "post" ], "api_allow_update": [ "boolean", false ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/addresses" ], "uri": [ "string", "http://localhost:8082/addresses" ], "api_denormalize": [ "boolean", true ], "cache_key": [ "string", "2d51165683a23cc89b05ec2cfbca3ff3" ] } ], [ "object", "ReflectionClass" ], [ "array", [] ], [ "string", "jsonld" ] ] }, { "namespace": "Symfony\\Component\\Serializer\\Normalizer", "short_class": "AbstractObjectNormalizer", "class": "Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer", "type": "->", "function": "instantiateObject", "file": "/var/www/html/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php", "line": 283, "args": [ [ "array", [ [ "string", "/clients/1" ] ] ], [ "string", "App\\Entity\\User" ], [ "array", { "groups": [ "array", [ [ "string", "write_address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "post" ], "api_allow_update": [ "boolean", false ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/addresses" ], "uri": [ "string", "http://localhost:8082/addresses" ], "api_denormalize": [ "boolean", true ], "cache_key": [ "string", "2d51165683a23cc89b05ec2cfbca3ff3" ] } ], [ "object", "ReflectionClass" ], [ "array", [] ], [ "string", "jsonld" ] ] }, { "namespace": "Symfony\\Component\\Serializer\\Normalizer", "short_class": "AbstractObjectNormalizer", "class": "Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer", "type": "->", "function": "denormalize", "file": "/var/www/html/vendor/symfony/serializer/Serializer.php", "line": 191, "args": [ [ "string", "/clients/1" ], [ "string", "App\\Entity\\User" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "write_address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "post" ], "api_allow_update": [ "boolean", false ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/addresses" ], "uri": [ "string", "http://localhost:8082/addresses" ], "api_denormalize": [ "boolean", true ], "cache_key": [ "string", "2d51165683a23cc89b05ec2cfbca3ff3" ] } ] ] }, { "namespace": "Symfony\\Component\\Serializer", "short_class": "Serializer", "class": "Symfony\\Component\\Serializer\\Serializer", "type": "->", "function": "denormalize", "file": "/var/www/html/vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php", "line": 690, "args": [ [ "string", "/clients/1" ], [ "string", "App\\Entity\\User" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "write_address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "post" ], "api_allow_update": [ "boolean", false ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/addresses" ], "uri": [ "string", "http://localhost:8082/addresses" ], "api_denormalize": [ "boolean", true ], "cache_key": [ "string", "2d51165683a23cc89b05ec2cfbca3ff3" ] } ] ] }, { "namespace": "ApiPlatform\\Core\\Serializer", "short_class": "AbstractItemNormalizer", "class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer", "type": "->", "function": "createAttributeValue", "file": "/var/www/html/vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php", "line": 350, "args": [ [ "string", "owner" ], [ "string", "/clients/1" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "write_address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "post" ], "api_allow_update": [ "boolean", false ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/addresses" ], "uri": [ "string", "http://localhost:8082/addresses" ], "api_denormalize": [ "boolean", true ], "cache_key": [ "string", "2d51165683a23cc89b05ec2cfbca3ff3" ] } ] ] }, { "namespace": "ApiPlatform\\Core\\Serializer", "short_class": "AbstractItemNormalizer", "class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer", "type": "->", "function": "setAttributeValue", "file": "/var/www/html/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php", "line": 300, "args": [ [ "object", "App\\Entity\\Address" ], [ "string", "owner" ], [ "string", "/clients/1" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "write_address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "post" ], "api_allow_update": [ "boolean", false ], "resource_class": [ "string", "App\\Entity\\Address" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/addresses" ], "uri": [ "string", "http://localhost:8082/addresses" ], "api_denormalize": [ "boolean", true ], "cache_key": [ "string", "2d51165683a23cc89b05ec2cfbca3ff3" ] } ] ] }, { "namespace": "Symfony\\Component\\Serializer\\Normalizer", "short_class": "AbstractObjectNormalizer", "class": "Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer", "type": "->", "function": "denormalize", "file": "/var/www/html/vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php", "line": 219, "args": [ [ "array", { "googlePlaceId": [ "string", "string" ], "sessionToken": [ "string", "string" ], "houseCode": [ "string", "string" ], "extraInformation": [ "string", "string" ], "owner": [ "string", "/clients/1" ] } ], [ "string", "App\\Entity\\Address" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "write_address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "post" ], "api_allow_update": [ "boolean", false ], "resource_class": [ "string", "App\\Entity\\Address" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/addresses" ], "uri": [ "string", "http://localhost:8082/addresses" ], "api_denormalize": [ "boolean", true ], "cache_key": [ "string", "2d51165683a23cc89b05ec2cfbca3ff3" ] } ] ] }, { "namespace": "ApiPlatform\\Core\\Serializer", "short_class": "AbstractItemNormalizer", "class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer", "type": "->", "function": "denormalize", "file": "/var/www/html/vendor/api-platform/core/src/JsonLd/Serializer/ItemNormalizer.php", "line": 117, "args": [ [ "array", { "googlePlaceId": [ "string", "string" ], "sessionToken": [ "string", "string" ], "houseCode": [ "string", "string" ], "extraInformation": [ "string", "string" ], "owner": [ "string", "/clients/1" ] } ], [ "string", "App\\Entity\\Address" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "write_address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "post" ], "api_allow_update": [ "boolean", false ], "resource_class": [ "string", "App\\Entity\\Address" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/addresses" ], "uri": [ "string", "http://localhost:8082/addresses" ], "api_denormalize": [ "boolean", true ] } ] ] }, { "namespace": "ApiPlatform\\Core\\JsonLd\\Serializer", "short_class": "ItemNormalizer", "class": "ApiPlatform\\Core\\JsonLd\\Serializer\\ItemNormalizer", "type": "->", "function": "denormalize", "file": "/var/www/html/vendor/symfony/serializer/Serializer.php", "line": 191, "args": [ [ "array", { "googlePlaceId": [ "string", "string" ], "sessionToken": [ "string", "string" ], "houseCode": [ "string", "string" ], "extraInformation": [ "string", "string" ], "owner": [ "string", "/clients/1" ] } ], [ "string", "App\\Entity\\Address" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "write_address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "post" ], "api_allow_update": [ "boolean", false ], "resource_class": [ "string", "App\\Entity\\Address" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/addresses" ], "uri": [ "string", "http://localhost:8082/addresses" ] } ] ] }, { "namespace": "Symfony\\Component\\Serializer", "short_class": "Serializer", "class": "Symfony\\Component\\Serializer\\Serializer", "type": "->", "function": "denormalize", "file": "/var/www/html/vendor/symfony/serializer/Serializer.php", "line": 142, "args": [ [ "array", { "googlePlaceId": [ "string", "string" ], "sessionToken": [ "string", "string" ], "houseCode": [ "string", "string" ], "extraInformation": [ "string", "string" ], "owner": [ "string", "/clients/1" ] } ], [ "string", "App\\Entity\\Address" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "write_address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "post" ], "api_allow_update": [ "boolean", false ], "resource_class": [ "string", "App\\Entity\\Address" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/addresses" ], "uri": [ "string", "http://localhost:8082/addresses" ] } ] ] }, { "namespace": "Symfony\\Component\\Serializer", "short_class": "Serializer", "class": "Symfony\\Component\\Serializer\\Serializer", "type": "->", "function": "deserialize", "file": "/var/www/html/vendor/api-platform/core/src/EventListener/DeserializeListener.php", "line": 100, "args": [ [ "array", { "googlePlaceId": [ "string", "string" ], "sessionToken": [ "string", "string" ], "houseCode": [ "string", "string" ], "extraInformation": [ "string", "string" ], "owner": [ "string", "/clients/1" ] } ], [ "string", "App\\Entity\\Address" ], [ "string", "jsonld" ], [ "array", { "groups": [ "array", [ [ "string", "write_address" ] ] ], "operation_type": [ "string", "collection" ], "collection_operation_name": [ "string", "post" ], "api_allow_update": [ "boolean", false ], "resource_class": [ "string", "App\\Entity\\Address" ], "input": [ "null", null ], "output": [ "null", null ], "request_uri": [ "string", "/addresses" ], "uri": [ "string", "http://localhost:8082/addresses" ] } ] ] }, { "namespace": "ApiPlatform\\Core\\EventListener", "short_class": "DeserializeListener", "class": "ApiPlatform\\Core\\EventListener\\DeserializeListener", "type": "->", "function": "onKernelRequest", "file": "/var/www/html/vendor/symfony/event-dispatcher/Debug/WrappedListener.php", "line": 115, "args": [ [ "object", "Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent" ], [ "string", "kernel.request" ], [ "object", "Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher" ] ] }, { "namespace": "Symfony\\Component\\EventDispatcher\\Debug", "short_class": "WrappedListener", "class": "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener", "type": "->", "function": "__invoke", "file": "/var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php", "line": 212, "args": [ [ "object", "Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent" ], [ "string", "kernel.request" ], [ "object", "Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher" ] ] }, { "namespace": "Symfony\\Component\\EventDispatcher", "short_class": "EventDispatcher", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "function": "doDispatch", "file": "/var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php", "line": 44, "args": [ [ "array", [ [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ], [ "object", "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener" ] ] ], [ "string", "kernel.request" ], [ "object", "Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent" ] ] }, { "namespace": "Symfony\\Component\\EventDispatcher", "short_class": "EventDispatcher", "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher", "type": "->", "function": "dispatch", "file": "/var/www/html/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php", "line": 145, "args": [ [ "string", "kernel.request" ], [ "object", "Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent" ] ] }, { "namespace": "Symfony\\Component\\EventDispatcher\\Debug", "short_class": "TraceableEventDispatcher", "class": "Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher", "type": "->", "function": "dispatch", "file": "/var/www/html/vendor/symfony/http-kernel/HttpKernel.php", "line": 126, "args": [ [ "string", "kernel.request" ], [ "object", "Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent" ] ] }, { "namespace": "Symfony\\Component\\HttpKernel", "short_class": "HttpKernel", "class": "Symfony\\Component\\HttpKernel\\HttpKernel", "type": "->", "function": "handleRaw", "file": "/var/www/html/vendor/symfony/http-kernel/HttpKernel.php", "line": 67, "args": [ [ "object", "Symfony\\Component\\HttpFoundation\\Request" ], [ "integer", 1 ] ] }, { "namespace": "Symfony\\Component\\HttpKernel", "short_class": "HttpKernel", "class": "Symfony\\Component\\HttpKernel\\HttpKernel", "type": "->", "function": "handle", "file": "/var/www/html/vendor/symfony/http-kernel/Kernel.php", "line": 198, "args": [ [ "object", "Symfony\\Component\\HttpFoundation\\Request" ], [ "integer", 1 ], [ "boolean", true ] ] }, { "namespace": "Symfony\\Component\\HttpKernel", "short_class": "Kernel", "class": "Symfony\\Component\\HttpKernel\\Kernel", "type": "->", "function": "handle", "file": "/var/www/html/public/index.php", "line": 25, "args": [ [ "object", "Symfony\\Component\\HttpFoundation\\Request" ] ] } ] }By the way, thank you for this wonderful framework ❤️
Beta Was this translation helpful? Give feedback.
All reactions