diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 7f757a79c..7c8b5f2e6 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1322,7 +1322,7 @@ class Model extends Object { if ($options['callbacks'] === true || $options['callbacks'] === 'before') { $result = $this->Behaviors->trigger('beforeSave', array(&$this, $options), array( - 'break' => true, 'breakOn' => false + 'break' => true, 'breakOn' => array(false, null) )); if (!$result || !$this->beforeSave($options)) { $this->whitelist = $_whitelist; @@ -1854,7 +1854,7 @@ class Model extends Object { $filters = $this->Behaviors->trigger( 'beforeDelete', array(&$this, $cascade), - array('break' => true, 'breakOn' => false) + array('break' => true, 'breakOn' => array(false, null)) ); if (!$filters || !$this->exists()) { return false; @@ -1876,7 +1876,7 @@ class Model extends Object { if (!empty($this->belongsTo)) { $this->updateCounterCache($keys[$this->alias]); } - $this->Behaviors->trigger($this, 'afterDelete'); + $this->Behaviors->trigger('afterDelete', array(&$this)); $this->afterDelete(); $this->_clearCache(); $this->id = false; @@ -2142,8 +2142,8 @@ class Model extends Object { if ($query['callbacks'] === true || $query['callbacks'] === 'before') { $return = $this->Behaviors->trigger( 'beforeFind', - array(&$this, $query), - array('break' => true, 'breakOn' => false, 'modParams' => 1) + array(&$this, $query), + array('break' => true, 'breakOn' => array(false, null), 'modParams' => 1) ); $query = (is_array($return)) ? $return : $query; diff --git a/cake/libs/model/model_behavior.php b/cake/libs/model/model_behavior.php index 192b21b72..46ad69165 100644 --- a/cake/libs/model/model_behavior.php +++ b/cake/libs/model/model_behavior.php @@ -80,7 +80,7 @@ class ModelBehavior extends Object { * * @param object $model Model using this behavior * @param array $queryData Data used to execute this query, i.e. conditions, order, etc. - * @return mixed False if the operation should abort. An array will replace the value of $query. + * @return mixed False or null will abort the operation. You should array will replace the value of $query. * @access public */ public function beforeFind($model, $query) { } @@ -100,10 +100,12 @@ class ModelBehavior extends Object { * Before validate callback * * @param object $model Model using this behavior - * @return mixed False if the operation should abort. Any other result will continue. + * @return mixed False or null will abort the operation. Any other result will continue. * @access public */ - public function beforeValidate($model) { } + public function beforeValidate($model) { + return true; + } /** * Before save callback @@ -112,7 +114,9 @@ class ModelBehavior extends Object { * @return mixed False if the operation should abort. Any other result will continue. * @access public */ - public function beforeSave($model) { } + public function beforeSave($model) { + return true; + } /** * After save callback @@ -120,7 +124,9 @@ class ModelBehavior extends Object { * @param object $model Model using this behavior * @param boolean $created True if this save created a new record */ - public function afterSave($model, $created) { } + public function afterSave($model, $created) { + return true; + } /** * Before delete callback @@ -130,7 +136,9 @@ class ModelBehavior extends Object { * @return mixed False if the operation should abort. Any other result will continue. * @access public */ - public function beforeDelete($model, $cascade = true) { } + public function beforeDelete($model, $cascade = true) { + return true; + } /** * After delete callback