diff --git a/lib/Cake/Console/Templates/default/actions/controller_actions.ctp b/lib/Cake/Console/Templates/default/actions/controller_actions.ctp index 8a943b9e7cf..0cde5c63830 100644 --- a/lib/Cake/Console/Templates/default/actions/controller_actions.ctp +++ b/lib/Cake/Console/Templates/default/actions/controller_actions.ctp @@ -131,12 +131,11 @@ * @return void */ public function delete($id = null) { - $this->->id = $id; - if (!$this->->exists()) { + if (!$this->->exists($id)) { throw new NotFoundException(__('Invalid ')); } $this->request->allowMethod('post', 'delete'); - if ($this->->delete()) { + if ($this->->delete($id)) { $this->Flash->success(__('The has been deleted.')); } else { diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index 9fc12e70637..d944007be44 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -225,7 +225,7 @@ public function beforeSave(Model $Model, $options = array()) { } $parentIsSet = array_key_exists($parent, $Model->data[$Model->alias]); - if (!$Model->id || !$Model->exists()) { + if (!$Model->id || !$Model->exists($Model->getID())) { if ($parentIsSet && $Model->data[$Model->alias][$parent]) { $parentNode = $this->_getNode($Model, $Model->data[$Model->alias][$parent]); if (!$parentNode) { diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 1af4f9eee48..ba790a94524 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -2547,7 +2547,7 @@ public function defaultConditions(Model $Model, $conditions, $useAlias = true) { if (!empty($conditions)) { return $conditions; } - $exists = $Model->exists(); + $exists = $Model->exists($Model->getID()); if (!$exists && ($conditions !== null || !empty($Model->__safeUpdateMode))) { return false; } elseif (!$exists) { diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 44df5c8e7da..1957baf8311 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -1824,7 +1824,7 @@ protected function _doSave($data = null, $options = array()) { } } - $exists = $this->exists(); + $exists = $this->exists($this->getID()); $dateFields = array('modified', 'updated'); if (!$exists) { @@ -2696,7 +2696,7 @@ public function delete($id = null, $cascade = true) { return false; } - if (!$this->exists()) { + if (!$this->exists($this->getID())) { return false; } diff --git a/lib/Cake/Model/ModelValidator.php b/lib/Cake/Model/ModelValidator.php index 9ab4f3f2a9b..406c0816cc9 100644 --- a/lib/Cake/Model/ModelValidator.php +++ b/lib/Cake/Model/ModelValidator.php @@ -257,7 +257,7 @@ public function errors($options = array()) { } } - $exists = $model->exists(); + $exists = $model->exists($model->getID()); $methods = $this->getMethods(); $fields = $this->_validationList($fieldList); diff --git a/lib/Cake/Test/bake_compare/Controller/ActionsUsingSessions.ctp b/lib/Cake/Test/bake_compare/Controller/ActionsUsingSessions.ctp index b4072d770e9..34e3fc23f7f 100644 --- a/lib/Cake/Test/bake_compare/Controller/ActionsUsingSessions.ctp +++ b/lib/Cake/Test/bake_compare/Controller/ActionsUsingSessions.ctp @@ -77,12 +77,11 @@ * @return void */ public function delete($id = null) { - $this->BakeArticle->id = $id; - if (!$this->BakeArticle->exists()) { + if (!$this->BakeArticle->exists($id)) { throw new NotFoundException(__('Invalid bake article')); } $this->request->allowMethod('post', 'delete'); - if ($this->BakeArticle->delete()) { + if ($this->BakeArticle->delete($id)) { $this->Flash->success(__('The bake article has been deleted.')); } else { $this->Flash->error(__('The bake article could not be deleted. Please, try again.')); diff --git a/lib/Cake/Test/bake_compare/Controller/ActionsWithNoSessions.ctp b/lib/Cake/Test/bake_compare/Controller/ActionsWithNoSessions.ctp index d3f5b19d591..cfdd24f7fd9 100644 --- a/lib/Cake/Test/bake_compare/Controller/ActionsWithNoSessions.ctp +++ b/lib/Cake/Test/bake_compare/Controller/ActionsWithNoSessions.ctp @@ -71,12 +71,11 @@ * @return void */ public function delete($id = null) { - $this->BakeArticle->id = $id; - if (!$this->BakeArticle->exists()) { + if (!$this->BakeArticle->exists($id)) { throw new NotFoundException(__('Invalid bake article')); } $this->request->allowMethod('post', 'delete'); - if ($this->BakeArticle->delete()) { + if ($this->BakeArticle->delete($id)) { return $this->flash(__('The bake article has been deleted.'), array('action' => 'index')); } else { return $this->flash(__('The bake article could not be deleted. Please, try again.'), array('action' => 'index'));