From: avl Date: Tue, 23 Dec 2008 10:25:45 +0000 (+0200) Subject: fix UB for m2m X-Git-Tag: 0.5~434 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=5b49112cdd6534e3b280b614b85ddf15ef93f20b;p=ipf.git fix UB for m2m --- 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]);