Permalink
Browse files

Check data with isset() before accessing it.

Don't blindly access data that may not exist.

Fixes #2712
  • Loading branch information...
markstory committed Jan 26, 2014
1 parent cf16ae0 commit d7d8fc00d1834b2ec00ecca16c23d6913f8b8c4c
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/Cake/Model/Model.php
View
@@ -2026,7 +2026,9 @@ protected function _saveMulti($joined, $id, $db) {
* @return void
*/
public function updateCounterCache($keys = array(), $created = false) {
- $keys = empty($keys) ? $this->data[$this->alias] : $keys;
+ if (empty($keys) && isset($this->data[$this->alias])) {
+ $keys = $this->data[$this->alias];
+ }
$keys['old'] = isset($keys['old']) ? $keys['old'] : array();
foreach ($this->belongsTo as $parent => $assoc) {

0 comments on commit d7d8fc0

Please sign in to comment.