Code

Improved faiPackage performance
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 19 Apr 2006 10:26:55 +0000 (10:26 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 19 Apr 2006 10:26:55 +0000 (10:26 +0000)
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

plugins/admin/fai/class_faiPackage.inc

index 2e30084b7e5ae67c05f41466ec2177bb96eac2f3..7e72481f99b84beb4fe34b651cc44e2977d07add 100644 (file)
@@ -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;
       }
     }