Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.2.0

Bug #17245 Fetching empty attributes raises error, but attribute type is valid
Submitted: 2010-03-19 14:56 UTC
From: beni Assigned: beni
Status: Closed Package: Net_LDAP2 (version 2.0.9)
PHP Version: Irrelevant OS:
Roadmaps: 2.1.0    
Subscription  


 [2010-03-19 14:56 UTC] beni (Benedikt Hallinger)
Description: ------------ When an entry is searched, with attributes requested that are empty at the server, and those attributes are tried to be fetched with getValue(), an error is dropped ("Unknown attribute ($attr) requested"). This is because when retrieving the entry from the server, the internal _attributes array is not initialized properly. The attributes that are empty at the server should be present as empty array elements there to indicate emptiness. When fixing this, all other manipulating functions (like add(), modify() etc) must be checked to adapt the new structure of _attributes.

Comments

 [2010-03-19 14:56 UTC] beni (Benedikt Hallinger)
-Assigned To: +Assigned To: beni
 [2010-03-19 14:59 UTC] beni (Benedikt Hallinger)
Alternatively, and maybe more easily to introduce, is some information the check in getValues() could use which is supplied to the entry by LDAP2->search() to indicate to it, which attribute types are really there but empty or not defined for the entry.
 [2010-03-19 15:07 UTC] beni (Benedikt Hallinger)
getValue() should do an schema check. This schema check should be optional for performance reasons.
 [2010-03-19 15:25 UTC] beni (Benedikt Hallinger)
A temporary fix until the checking code is avialable: public function getValue($attr, $option = null) { $attr = $this->getAttrName($attr); // This check is not entirely correct. If attributes are requested that are empty, // they do not went into the _attributes array (since this attibute is not set at the entry) // This check should be done against the schema, to see if the attribute // is present at one of the entrys objectClasses. // If this is the case, we can return 0, false or '' depending on the attributes syntax. // If the attribute is not valid for this entries objectClass(es), we should drop the error below. if (false == array_key_exists($attr, $this->_attributes)) { //return PEAR::raiseError("Unknown attribute ($attr) requested"); return null; } $value = $this->_attributes[$attr]; if ($option == "single" || (count($value) == 1 && $option != 'all')) { $value = array_shift($value); } return $value; }
 [2010-03-22 12:54 UTC] beni (Benedikt Hallinger)
A temporary fix is introduced in SVN. It incorporates a schema check. This check must now be narrowed to the attributs available in the entries object classes.
 [2010-03-23 11:34 UTC] beni (Benedikt Hallinger)
-Status: Assigned +Status: Closed
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. This bug has been fixed: - getValue(); the invalid check from <2.0.9 was removed - schema class: new check methods where introduced so users can easily perform schema checks on their own. This allows for maximum flexibility since schema checks are not always necessary (and performance costly).