lib/api

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Wed Sep 5 10:07:03 CEST 2012


 lib/api/kolab_api_service_form_value.php |   22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

New commits:
commit 83537043c792be58aec58eb548acedafb1f0eb98
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Wed Sep 5 09:06:33 2012 +0100

    Test for result values before using the results as if they were valid (#987)

diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index d5eaf87..4936f30 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -781,13 +781,21 @@ class kolab_api_service_form_value extends kolab_api_service
 
         if (!empty($postdata['id'])) {
             $subjects = $auth->search($base_dn, '(' . $unique_attr . '=' . $postdata['id'] . ')')->entries(TRUE);
-            $subject = array_shift($subjects);
-            $subject_dn = key($subject);
-            $subject_dn_components = ldap_explode_dn($subject_dn, 0);
-            unset($subject_dn_components['count']);
-            array_shift($subject_dn_components);
-            $default = strtolower(implode(',', $subject_dn_components));
-        } else {
+
+            if ($subjects) {
+                $subject = array_shift($subjects);
+                $subject_dn = key($subject);
+                $subject_dn_components = ldap_explode_dn($subject_dn, 0);
+
+                if ($subject_dn_components) {
+                    unset($subject_dn_components['count']);
+                    array_shift($subject_dn_components);
+                    $default = strtolower(implode(',', $subject_dn_components));
+                }
+            }
+        }
+
+        if (empty($default)) {
             $default = $base_dn;
         }
 





More information about the commits mailing list