Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntityNotFoundException using softDeletable #101

Closed
BraisGabin opened this issue Jun 7, 2013 · 4 comments
Closed

EntityNotFoundException using softDeletable #101

BraisGabin opened this issue Jun 7, 2013 · 4 comments

Comments

@BraisGabin
Copy link
Contributor

In my API'm using softDeletable. This makes JMSSerialize throw the exception: EntityNotFoundException.

Example: A post with an author. I soft-delete the author and request the post.

The expected json is:

"author": null

I tried to fix this problem and submit a PR but I couldn't fix it.

Any clues on how to do it?

Related:
http://stackoverflow.com/q/11057504/842697
https://github.com/l3pp4rd/DoctrineExtensions/issues/505#issuecomment-13351451


My really poor solution:

I can prevent the Exception with this:

try{
    $object->__load();
} catch (\Doctrine\ORM\EntityNotFoundException $e) {
    return;
}

at DoctrineProxySubscriber.php#L51.

The result is:

"author": {}

And I really don't know the collateral problems of this.

@nrutman
Copy link

nrutman commented Nov 14, 2013

I'm encountering this all over the place. The problem is that JMS Serializer sees the key in post to author, but when it tries to fetch the author Doctrine says it doesn't exist (because it has been soft deleted).

I'm not sure how to go about this properly. It seems like a huge use case.

@stof
Copy link
Contributor

stof commented Nov 14, 2013

@BraisGabin Any code in your app accessing the author will break if you soft delete it but you are still referencing it in a relation in another object. It is not a JMSSerializer issue.

@BraisGabin
Copy link
Contributor Author

@stof I know that a post can have a soft deleted author in my model. So I check it in my code. The problem here is: how can I manage this inside JMSSerializer? Probabily it's not a JMSSerializer issue but a feature.

@stof
Copy link
Contributor

stof commented Jan 27, 2014

you could use a custom exclusion strategy to exclude the author in such case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants