Check data with isset() before accessing it.

Don't blindly access data that may not exist.

Fixes #2712
This commit is contained in:
mark_story 2014-01-25 22:15:47 -05:00
parent cf16ae055f
commit d7d8fc00d1

View file

@ -2026,7 +2026,9 @@ class Model extends Object implements CakeEventListener {
* @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) {