Skip to content

Commit

Permalink
Fixing notice errors caused by trying to operate on keys that don't e…
Browse files Browse the repository at this point in the history
…xist.

Fixes #1651
  • Loading branch information
markstory committed May 31, 2011
1 parent 9402f66 commit cd8b18d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cake/libs/controller/components/cookie.php
Expand Up @@ -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) . ']');
}

Expand Down
10 changes: 10 additions & 0 deletions cake/tests/cases/libs/controller/components/cookie.test.php
Expand Up @@ -468,6 +468,16 @@ function testDeleteRemovesChildren() {
$this->Controller->Cookie->destroy();
}

/**
* 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
*
Expand Down

0 comments on commit cd8b18d

Please sign in to comment.