From 5b49112cdd6534e3b280b614b85ddf15ef93f20b Mon Sep 17 00:00:00 2001 From: avl Date: Tue, 23 Dec 2008 12:25:45 +0200 Subject: [PATCH] fix UB for m2m --- ipf/form/model.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ipf/form/model.php b/ipf/form/model.php index 499a8cc..0e447b9 100644 --- a/ipf/form/model.php +++ b/ipf/form/model.php @@ -46,8 +46,14 @@ class IPF_Form_Model extends IPF_Form } if (array_key_exists($uname,$db_columns)) $this->addDBField($uname,$db_columns[$uname]); - elseif (array_key_exists($uname,$db_relations)) - $this->addDBRelation($uname,$db_relations[$uname],$db_columns[$db_relations[$uname]->getLocalFieldName()]); + elseif (array_key_exists($uname,$db_relations)){ + $lfn = $db_relations[$uname]->getLocalFieldName(); + if (isset($db_columns[$lfn])) + $col = $db_columns[$lfn]; + else + $col = array(); + $this->addDBRelation($uname,$db_relations[$uname],$col); + } } } } @@ -122,9 +128,7 @@ class IPF_Form_Model extends IPF_Form $rels = $this->model->getTable()->getRelations(); foreach($rels as $rname=>$rel){ - //print "$rname
"; if (isset($this->cleaned_data[$rname])){ - //print $rel->getAlias(); $this->model->unlink($rel->getAlias()); if (is_array($this->cleaned_data[$rname])){ $this->model->link($rel->getAlias(),$this->cleaned_data[$rname]); -- 2.49.0