From 1e1fcabb3de2c8f8b4c909f3ea178d0d4161a6ea Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 6 Oct 2011 14:29:35 +1100 Subject: [PATCH] SF Bug #3398344 - Import LDIF overwrites entries --- lib/Template.php | 4 ++-- lib/ds_ldap.php | 4 ++-- lib/import_functions.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Template.php b/lib/Template.php index e145753..4b4a28b 100644 --- a/lib/Template.php +++ b/lib/Template.php @@ -258,7 +258,7 @@ class Template extends xmlTemplate { * or delete. * (OLD values are IGNORED, we will have got them when we build this object from the LDAP server DN.) */ - public function accept($makeVisible=false) { + public function accept($makeVisible=false,$nocache=false) { if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); @@ -275,7 +275,7 @@ class Template extends xmlTemplate { $rdnarray = rdn_explode(strtolower(get_rdn(dn_escape($this->dn)))); $counter = 1; - foreach ($server->getDNAttrValues($this->dn,null,LDAP_DEREF_NEVER,array_merge(array('*'),$server->getValue('server','custom_attrs'))) as $attr => $values) { + foreach ($server->getDNAttrValues($this->dn,null,LDAP_DEREF_NEVER,array_merge(array('*'),$server->getValue('server','custom_attrs')),$nocache) as $attr => $values) { # We ignore DNs. if ($attr == 'dn') continue; diff --git a/lib/ds_ldap.php b/lib/ds_ldap.php index 493d0cb..dea177f 100644 --- a/lib/ds_ldap.php +++ b/lib/ds_ldap.php @@ -2001,7 +2001,7 @@ class ldap extends DS { * @see getDNSysAttrs * @see getDNAttrValue */ - public function getDNAttrValues($dn,$method=null,$deref=LDAP_DEREF_NEVER,$attrs=array('*','+')) { + public function getDNAttrValues($dn,$method=null,$deref=LDAP_DEREF_NEVER,$attrs=array('*','+'),$nocache=false) { if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); @@ -2017,7 +2017,7 @@ class ldap extends DS { elseif (in_array('*',$attrs)) $cacheindex = '*'; - if (! is_null($cacheindex) && isset($CACHE[$this->index][$method][$dn][$cacheindex])) { + if (! $nocache && ! is_null($cacheindex) && isset($CACHE[$this->index][$method][$dn][$cacheindex])) { $results = $CACHE[$this->index][$method][$dn][$cacheindex]; if (DEBUG_ENABLED) diff --git a/lib/import_functions.php b/lib/import_functions.php index 8ef40be..3442b01 100644 --- a/lib/import_functions.php +++ b/lib/import_functions.php @@ -215,7 +215,7 @@ class ImportLDIF extends Import { return $this->error(sprintf('%s %s',_('DN does not exist'),$dn),$lines); $this->template->setDN($dn); - $this->template->accept(); + $this->template->accept(false,true); return $this->getModifyDetails($lines); @@ -511,7 +511,7 @@ class ImportLDIF extends Import { case 'delete': $deleteattr = false; - if ($key = array_search($attribute_value_part,$attribute->getValues())) + if (($key = array_search($attribute_value_part,$attribute->getValues())) !== false) $attribute->delValue($key); else return $this->error(sprintf('%s %s',_('Delete value doesnt exist in DN'),$attribute_value_part),