Permalink
Browse files

Fixing notice errors caused by trying to operate on keys that don't e…

…xist.

Fixes #1651
  • Loading branch information...
1 parent 9402f66 commit cd8b18d00db0c23281e7477264d4c826cd6ee0a6 @markstory markstory committed May 31, 2011
@@ -291,7 +291,9 @@ function delete($key) {
return;
}
$names = explode('.', $key, 2);
- $this->__values[$names[0]] = Set::remove($this->__values[$names[0]], $names[1]);
+ if (isset($this->__values[$names[0]])) {
+ $this->__values[$names[0]] = Set::remove($this->__values[$names[0]], $names[1]);
+ }
$this->__delete('[' . implode('][', $names) . ']');
}
@@ -469,6 +469,16 @@ function testDeleteRemovesChildren() {
}
/**
+ * Test deleting recursively with keys that don't exist.
+ *
+ * @return void
+ */
+ function testDeleteChildrenNotExist() {
+ $this->assertNull($this->Controller->Cookie->delete('NotFound'));
+ $this->assertNull($this->Controller->Cookie->delete('Not.Found'));
+ }
+
+/**
* encrypt method
*
* @param mixed $value

0 comments on commit cd8b18d

Please sign in to comment.