DDC-859: Datetime object changeset computing #1065

Closed
opened 2026-01-22 13:00:46 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 5, 2010).

Jira issue originally created by user gediminasm:

The problem is with Datetime value on entity, if I dirrecly modify it, unitOfWork will not add it into change set
// assume loaded entity through dql or repository:

$entity->getStartDate()->modify("+ 1day");
$em->persist($entity);
$em->flush(); // no changes

as far as I understand objects are compared through ($oldObject === $newObject) probably php takes spl_object_hash to do the comparison
copying an object works as expected

Originally created by @doctrinebot on GitHub (Nov 5, 2010). Jira issue originally created by user gediminasm: The problem is with Datetime value on entity, if I dirrecly modify it, unitOfWork will not add it into change set // assume loaded entity through dql or repository: $entity->getStartDate()->modify("+ 1day"); $em->persist($entity); $em->flush(); // no changes as far as I understand objects are compared through ($oldObject === $newObject) probably php takes spl_object_hash to do the comparison copying an object works as expected
admin added the New Feature label 2026-01-22 13:00:46 +01:00
admin closed this issue 2026-01-22 13:00:48 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 5, 2010):

Comment created by @beberlei:

This is expected behavior, DateTime objects are thought of as immutable value objects (php allowing them to be mutable is sort of a design mistake that even Derick sees now).

Only changing the instance will change the value, otherwise the difference computation would be too difficult and would involve cloning the datetime (overhead).

@doctrinebot commented on GitHub (Nov 5, 2010): Comment created by @beberlei: This is expected behavior, DateTime objects are thought of as immutable value objects (php allowing them to be mutable is sort of a design mistake that even Derick sees now). Only changing the instance will change the value, otherwise the difference computation would be too difficult and would involve cloning the datetime (overhead).
Author
Owner

@doctrinebot commented on GitHub (Nov 5, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Nov 5, 2010): 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#1065