From 7b79a7b98bdeb4c32eba4f288f152cddb8d91bba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baptiste=20=22Talus=22=20Clavi=C3=A9?= Date: Mon, 25 Nov 2013 16:17:57 +0100 Subject: [PATCH] Fixes a bug when detecting changes on a null value 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`. --- src/Totem/Set.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Totem/Set.php b/src/Totem/Set.php index 67f07b0..e2a2f0e 100644 --- a/src/Totem/Set.php +++ b/src/Totem/Set.php @@ -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; }