Skip to content
Browse files

Not comparing before and after values in Entity::set(), property is m…

…arked dirty whenever it is set
  • Loading branch information...
1 parent 8b341d9 commit fa77f26ce021c977662cb6df35f03e59c0d8bb3a @lorenzo lorenzo committed
Showing with 5 additions and 11 deletions.
  1. +1 −8 src/ORM/Entity.php
  2. +4 −3 tests/TestCase/ORM/EntityTest.php
View
9 src/ORM/Entity.php
@@ -248,14 +248,7 @@ public function set($property, $value = null, $options = []) {
continue;
}
- $markDirty = true;
- if (isset($this->_properties[$p])) {
- $markDirty = $value !== $this->_properties[$p];
- }
-
- if ($markDirty) {
- $this->dirty($p, true);
- }
+ $this->dirty($p, true);
if (!$options['setter']) {
$this->_properties[$p] = $value;
View
7 tests/TestCase/ORM/EntityTest.php
@@ -507,13 +507,14 @@ public function testDirtyChangingProperties() {
$entity = new Entity([
'title' => 'Foo',
]);
+
$entity->dirty('title', false);
$this->assertFalse($entity->dirty('title'));
+
$entity->set('title', 'Foo');
- $this->assertFalse($entity->dirty('title'));
+ $this->assertTrue($entity->dirty('title'));
+
$entity->set('title', 'Foo');
- $this->assertFalse($entity->dirty('title'));
- $entity->set('title', 'Something Else');
$this->assertTrue($entity->dirty('title'));
$entity->set('something', 'else');

0 comments on commit fa77f26

Please sign in to comment.
Something went wrong with that request. Please try again.