[PR #807] [MERGED] Fix for OptimisticLockingException #8729

Closed
opened 2026-01-22 16:01:24 +01:00 by admin · 0 comments
Owner

📋 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: masterHead: fix-optimisticlock


📝 Commits (2)

  • a4e3921 When 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.
  • f64d669 Removed 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.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/807 **Author:** [@janbster](https://github.com/janbster) **Created:** 10/1/2013 **Status:** ✅ Merged **Merged:** 10/1/2013 **Merged by:** [@guilhermeblanco](https://github.com/guilhermeblanco) **Base:** `master` ← **Head:** `fix-optimisticlock` --- ### 📝 Commits (2) - [`a4e3921`](https://github.com/doctrine/orm/commit/a4e39210903efe3919194c8ac7819068867cb9cb) When 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. - [`f64d669`](https://github.com/doctrine/orm/commit/f64d6695ce267e0b77efe73723783103f6553a9b) Removed unnecessary is_object() check ### 📊 Changes **2 files changed** (+36 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `lib/Doctrine/ORM/OptimisticLockException.php` (+2 -0) 📝 `tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php` (+34 -1) </details> ### 📄 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 16:01:24 +01:00
admin closed this issue 2026-01-22 16:01:25 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#8729