-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
Fallback to native entity if no revision found for properties #227
Fallback to native entity if no revision found for properties #227
Conversation
@soullivaneuh would you mind writing a test that covers this case? quick question: what happens, if the find-query doesn't succeed either? Wouldn't this throw a 'new' exception (which might need conversion to NoRevisionFoundException)? |
I'll look at it.
You are right. I'll throw the exception again if no result is found. |
3539c02
to
15152a3
Compare
@tolry After reflection, I'm not sure this way is the good way. Indeed, this method is here to find an entity at a specific revision. This make no sense to return another entity if the revision does not exist. Two possible solution:
What do you think? |
Ok now I remember why I did this. This is for relation. Indeed, on my code, I list all revision of an entity before finding them: $ticketRevisions = array_reverse($this->auditReader->findRevisions(Ticket::class, $ticket->getId()));
foreach ($ticketRevisions as $revision) {
$currentTicketVersion = $this->auditReader->find(Ticket::class, $ticket->getId(), $revision->getRev()); So there is no way to have a But the reader also tries to find related entities at the same revision. And at this case, it fails. So we should add a |
Ok so just forget all my comments. The PR is right because the fallback is done only for properties here. This happen when you didn't update a PR from a long time... 😛 I'm looking for testing. |
15152a3
to
2cd65ad
Compare
@tolry Tests added. Failing Travis seems to not be related to this PR. Something looks wrong with pgsql... |
2cd65ad
to
f157b88
Compare
I have an issue with MySQL: https://travis-ci.org/simplethings/EntityAudit/jobs/188847686#L305 I can't delete the related object of article to test the exception re-throw. Actually, the |
👍 yes, i think so too. |
@DavidBadura will do. I saw the 1.0.0 release was done with the related branch. As it's a bugfix, should I change the target branch for 1.0? |
f157b88
to
30cf7c7
Compare
done |
👍 LGTM |
If an audited entity has relational properties, the reader will try to find them as the same version, or previous. But if the targeted class does not has any revision at all, this produces a NoRevisionFound exception. This should be catched and should fallback to a classic doctrine find query.
30cf7c7
to
d2dc9a0
Compare
@DavidBadura I just fixed the tests, it should be OK now. |
thanks! |
Thanks you too! Any chance to have a patch release for this? This is related to a quite critical issue. |
ping @DavidBadura? :-) |
I'll make it this week |
@DavidBadura Please wait a little before make a new release, I found a bug with reverse relations. I'm working on a patch. |
If an audited entity has relational properties, the reader will try to find them as the same version, or previous.
But if the targeted class does not has any revision at all, this produces a NoRevisionFound exception.
This should be catched and should fallback to a classic doctrine find query.
Concrete error with stack trace:
Basically, the reader try to find a
User
instance of a specified revision because it's a property of theTicket
instance.But after a fresh deploy, existing
User
instances does not has any revision yet.Could you please push a new patch release after merging this? This is quite critical.
Regards.
fix #157