Skip to content

Commit

Permalink
Not comparing before and after values in Entity::set(), property is m…
Browse files Browse the repository at this point in the history
…arked dirty whenever it is set
  • Loading branch information
lorenzo committed Feb 15, 2014
1 parent 8b341d9 commit fa77f26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
9 changes: 1 addition & 8 deletions src/ORM/Entity.php
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions tests/TestCase/ORM/EntityTest.php
Expand Up @@ -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');
Expand Down

0 comments on commit fa77f26

Please sign in to comment.