mirror of
https://github.com/doctrine/orm.git
synced 2026-04-29 17:33:15 +02:00
[PR #807] [MERGED] Fix for OptimisticLockingException #8729
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/doctrine/orm/pull/807
Author: @janbster
Created: 10/1/2013
Status: ✅ Merged
Merged: 10/1/2013
Merged by: @guilhermeblanco
Base:
master← Head:fix-optimisticlock📝 Commits (2)
a4e3921When the OptimisticLockingException is generated with the static function 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.f64d669Removed unnecessary is_object() check📊 Changes
2 files changed (+36 additions, -1 deletions)
View changed files
📝
lib/Doctrine/ORM/OptimisticLockException.php(+2 -0)📝
tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php(+34 -1)📄 Description
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.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.