Permalink
Browse files

patched Entity->modified() for null values

  • Loading branch information...
1 parent 945859b commit 9157e4c26b58528adfb7382847fe37e294cf6451 @jmglsn jmglsn committed Apr 12, 2012
Showing with 7 additions and 4 deletions.
  1. +2 −2 data/Entity.php
  2. +5 −2 tests/cases/data/entity/DocumentTest.php
View
@@ -368,13 +368,13 @@ public function decrement($field, $value = 1) {
* `true` for changed fields.
*/
public function modified() {
- $fields = array_fill_keys(array_keys($this->_updated), false);
+ $fields = array_fill_keys(array_keys($this->_data), false);
foreach ($this->_updated as $field => $value) {
if (is_object($value) && method_exists($value, 'modified')) {
$modified = $value->modified();
$fields[$field] = $modified === true || is_array($modified) && in_array(true, $modified, true);
} else {
- $fields[$field] = !isset($this->_data[$field]) || $this->_data[$field] !== $this->_updated[$field];
+ $fields[$field] = !isset($fields[$field]) || $this->_data[$field] !== $this->_updated[$field];
}
}
return $fields;
@@ -134,12 +134,15 @@ public function testSyncModified() {
$doc->id = 5;
+ $doc->content = null;
+ $doc->new = null;
$expected = array(
'id' => true,
'name' => false,
- 'content' => false,
+ 'content' => true,
+ 'new' => true,
);
-
+
$this->assertEqual($expected, $doc->modified());
}

0 comments on commit 9157e4c

Please sign in to comment.