Skip to content

Commit

Permalink
Fixes a bug when detecting changes on a null value
Browse files Browse the repository at this point in the history
If the new value was equal to `null`, it was then always registered
as a `Removal` instead of possibly a `Addition` or `Modification`...
or not a change (in the case that the old value was also `null`).

This is due to the fact that `isset($a)` returns false even if the
key is set but its value is `null`.
  • Loading branch information
Taluu committed Nov 25, 2013
1 parent ddcb183 commit 7b79a7b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Totem/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private function compute(AbstractSnapshot $old, AbstractSnapshot $new)
$this->changes = [];

foreach ($old->getDataKeys() as $key) {
if (!isset($new[$key])) {
if (!in_array($key, $new->getDataKeys())) {
$this->changes[$key] = new Removal($old[$key] instanceof AbstractSnapshot ? $old[$key]->getRawData() : $old[$key]);
continue;
}
Expand Down

0 comments on commit 7b79a7b

Please sign in to comment.