Is CAKEPHP developer team planning to correct/adjust the _deleteLinks
function in the cake\libs\model\model.php ?
It ignores the conditions definition declared in the model.
-- Original code:
function _deleteLinks($id) {
foreach ($this->hasAndBelongsToMany as $assoc => $data) {
$records = $this->{$data['with']}->find('all', array(
'conditions' => array_merge(
array($this->{$data['with']}-
>escapeField($data['foreignKey']) => $id)),
'fields' => $this->{$data['with']}->primaryKey,
'recursive' => -1
));
if (!empty($records)) {
foreach ($records as $record) {
$this->{$data['with']}->delete($record[$this->{$data['with']}-
>alias][$this->{$data['with']}->primaryKey]);
}
}
}
}
-- Corrected code:
function _deleteLinks($id) {
foreach ($this->hasAndBelongsToMany as $assoc => $data) {
$records = $this->{$data['with']}->find('all', array(
'conditions' => array_merge(
array($this->{$data['with']}-
>escapeField($data['foreignKey']) => $id),
$data['conditions']),
'fields' => $this->{$data['with']}->primaryKey,
'recursive' => -1
));
if (!empty($records)) {
foreach ($records as $record) {
$this->{$data['with']}->delete($record[$this->{$data['with']}-
>alias][$this->{$data['with']}->primaryKey]);
}
}
}
}
The lack of the 'conditions' conditions in this function, makes cake
delete data that should not be deleted.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php