From: hickert Date: Wed, 19 Apr 2006 10:26:55 +0000 (+0000) Subject: Improved faiPackage performance X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3b0f21230c9ac05e3acb964ef13ea3b4d4cb2781;p=gosa.git Improved faiPackage performance Instead of calling ldap->search for each Package call ldap->search with all packages in a single search git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3062 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/fai/class_faiPackage.inc b/plugins/admin/fai/class_faiPackage.inc index 2e30084b7..7e72481f9 100644 --- a/plugins/admin/fai/class_faiPackage.inc +++ b/plugins/admin/fai/class_faiPackage.inc @@ -100,27 +100,37 @@ class faiPackage extends plugin $this->usedPackages = array(); } - $ldap = $this->config->get_ldap_link(); + + /* Create one filter with all package names, + instead of calling $ldap->search for every single package + */ + $PackageFilter = ""; foreach($this->usedPackages as $name){ - $ldap->search("(&(objectClass=FAIdebconfInfo)(FAIpackage=".$name."))",array("FAIvariable","FAIvariableType","FAIvariableContent","FAIpackage","FAIdebianSection","")); - while($attr = $ldap->fetch()){ - - $tmp =array(); - $tmp['Name'] = $attr['FAIvariable'][0]; - $tmp['Type'] = $attr['FAIvariableType'][0]; - - if (isset($attr['FAIvariableContent'][0])){ - if(!in_array($attr['FAIvariableType'],array("multiselect"))){ - $tmp['Value'] = $attr['FAIvariableContent'][0]; - }else{ - $content = array(); - unset($attr['FAIvariableContent']['count']); - foreach($attr['FAIvariableContent'] as $attr){ - $tmp['Value'][] = $attr; - } + $PackageFilter .= "(FAIpackage=".$name.")"; + } + $PackageFilter = "(&(objectClass=FAIdebconfInfo)(|".$PackageFilter."))"; + + /* Search for configuration objects */ + $ldap = $this->config->get_ldap_link(); + $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType","FAIvariableContent","FAIpackage","FAIdebianSection")); + + /* Walk through configurations and append them to our list of ConfiguredPackages */ + while($attr = $ldap->fetch()){ + $tmp =array(); + $tmp['Name'] = $attr['FAIvariable'][0]; + $tmp['Type'] = $attr['FAIvariableType'][0]; + + if (isset($attr['FAIvariableContent'][0])){ + if(!in_array($attr['FAIvariableType'],array("multiselect"))){ + $tmp['Value'] = $attr['FAIvariableContent'][0]; + }else{ + $content = array(); + unset($attr['FAIvariableContent']['count']); + foreach($attr['FAIvariableContent'] as $attr){ + $tmp['Value'][] = $attr; } - $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp; } + $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp; } }