diff --git a/cake/libs/model/behavior_collection.php b/cake/libs/model/behavior_collection.php index 7eaeef2be..aaeeb6da7 100644 --- a/cake/libs/model/behavior_collection.php +++ b/cake/libs/model/behavior_collection.php @@ -219,7 +219,10 @@ class BehaviorCollection extends ObjectCollection { } if (!empty($call)) { - return $this->_loaded[$call[1]]->dispatchMethod($model, $call[0], $params); + return call_user_func_array( + array(&$this->_loaded[$call[1]], $call[0]), + array_merge(array(&$model), $params) + ); } return array('unhandled'); } @@ -242,8 +245,10 @@ class BehaviorCollection extends ObjectCollection { $options ); foreach ($this->_enabled as $name) { - $result = $this->_loaded[$name]->dispatchMethod($model, $callback, $params); - + $result = call_user_func_array( + array(&$this->_loaded[$name], $callback), + array_merge(array(&$model), $params) + ); if ( $options['break'] && ($result === $options['breakOn'] || (is_array($options['breakOn']) && in_array($result, $options['breakOn'], true))) diff --git a/cake/libs/model/model_behavior.php b/cake/libs/model/model_behavior.php index 41342605c..8e621d4af 100644 --- a/cake/libs/model/model_behavior.php +++ b/cake/libs/model/model_behavior.php @@ -147,37 +147,6 @@ class ModelBehavior extends Object { */ public function onError(&$model, $error) { } -/** - * Overrides Object::dispatchMethod to account for PHP4's broken reference support - * - * @see Object::dispatchMethod - * @access public - * @return mixed - */ - function dispatchMethod(&$model, $method, $params = array()) { - if (empty($params)) { - return $this->{$method}($model); - } - $params = array_values($params); - - switch (count($params)) { - case 1: - return $this->{$method}($model, $params[0]); - case 2: - return $this->{$method}($model, $params[0], $params[1]); - case 3: - return $this->{$method}($model, $params[0], $params[1], $params[2]); - case 4: - return $this->{$method}($model, $params[0], $params[1], $params[2], $params[3]); - case 5: - return $this->{$method}($model, $params[0], $params[1], $params[2], $params[3], $params[4]); - default: - $params = array_merge(array(&$model), $params); - return call_user_func_array(array(&$this, $method), $params); - break; - } - } - /** * If $model's whitelist property is non-empty, $field will be added to it. * Note: this method should *only* be used in beforeValidate or beforeSave to ensure