Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

patched Entity->modified() for null values

  • Loading branch information...
commit 9157e4c26b58528adfb7382847fe37e294cf6451 1 parent 945859b
@jmglsn jmglsn authored
Showing with 7 additions and 4 deletions.
  1. +2 −2 data/Entity.php
  2. +5 −2 tests/cases/data/entity/DocumentTest.php
View
4 data/Entity.php
@@ -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;
View
7 tests/cases/data/entity/DocumentTest.php
@@ -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());
}
Please sign in to comment.
Something went wrong with that request. Please try again.