DDC-2715: [GH-807] Fix for OptimisticLockingException #3399

Closed
opened 2026-01-22 14:19:14 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Oct 1, 2013).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of janbster:

Url: https://github.com/doctrine/doctrine2/pull/807

Message:

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.

Originally created by @doctrinebot on GitHub (Oct 1, 2013). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of janbster: Url: https://github.com/doctrine/doctrine2/pull/807 Message: 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.
admin added the Bug label 2026-01-22 14:19:14 +01:00
admin closed this issue 2026-01-22 14:19:14 +01:00
Author
Owner

@doctrinebot commented on GitHub (Oct 1, 2013):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-807] was closed:
https://github.com/doctrine/doctrine2/pull/807

@doctrinebot commented on GitHub (Oct 1, 2013): Comment created by @doctrinebot: A related Github Pull-Request [GH-807] was closed: https://github.com/doctrine/doctrine2/pull/807
Author
Owner

@doctrinebot commented on GitHub (Oct 29, 2013):

Comment created by @beberlei:

Merged into 2.4 and 2.3 branches

@doctrinebot commented on GitHub (Oct 29, 2013): Comment created by @beberlei: Merged into 2.4 and 2.3 branches
Author
Owner

@doctrinebot commented on GitHub (Oct 29, 2013):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Oct 29, 2013): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3399