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

Fix for OptimisticLockingException #807

Merged
merged 2 commits into from Oct 1, 2013

Conversation

janbster
Copy link

@janbster janbster commented Oct 1, 2013

When using the $em->lock() method with an entity that uses a DateTime field for optimistic locking, and the optimistic locking fails, an OptimisticLockingException is generated Using the static method lockFailedVersionMismatch in OptimisticLockingException. In this case the parameters are of type DateTime. Therefore, the string for the exception message cannot be generated and you will get an error "Object of class DateTime could not be converted to string". I added a conversion to class to solve this problem.

I also changed the test OptimisticTest to actually test for this problem. If you run the tests without the changed OptimisticLockingException, you will see the error. I also modified the test to ensure that the Exception is actually thrown.

jan brunnert added 2 commits September 30, 2013 11:32
…tion lockFailedVersionMismatch and the passed parameters are DateTime instances, the exception could not be thrown because the DateTime object is not implicitly converted to a string.
@doctrinebot
Copy link

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DDC-2715

We use Jira to track the state of pull requests and the versions they got
included in.

@Majkl578
Copy link
Contributor

Majkl578 commented Oct 1, 2013

What about other non-scalar types: array, json_array, simple_array and object?

@janbster
Copy link
Author

janbster commented Oct 1, 2013

Hello Michael, as far as I understand from the documentation on optimistic locking, only integer and datetime types can be used for version fields. Maybe I am not seeing the whole picture here, what kind of change would you suggest? http://docs.doctrine-project.org/en/latest/reference/transactions-and-concurrency.html#optimistic-locking

@Majkl578
Copy link
Contributor

Majkl578 commented Oct 1, 2013

Ah, it should be ok then.

guilhermeblanco added a commit that referenced this pull request Oct 1, 2013
Fix for OptimisticLockingException
@guilhermeblanco guilhermeblanco merged commit 4051d0d into doctrine:master Oct 1, 2013
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

Successfully merging this pull request may close these issues.

None yet

4 participants