[bugs] [Bug 1000] New - bug in horde/Prefs/ldap.php and some
additional code...
bugs@bugs.horde.org
bugs@bugs.horde.org
Thu, 25 Jul 2002 05:09:49 -0300
http://bugs.horde.org/show_bug.cgi?id=1000
*** shadow/1000 Thu Jul 25 05:09:48 2002
--- shadow/1000.tmp.20122 Thu Jul 25 05:09:48 2002
***************
*** 0 ****
--- 1,119 ----
+ Bug#: 1000
+ Product: Horde
+ Version: 2.1 Unstable
+ Platform: PHP Code
+ OS/Version: Linux
+ Status: NEW
+ Resolution:
+ Severity: normal
+ Priority: P2
+ Component: Core
+ Area: BUILD
+ AssignedTo: chuck@horde.org
+ ReportedBy: jaaskela@ksao.fi
+ URL:
+ Summary: bug in horde/Prefs/ldap.php and some additional code...
+
+ hi.
+
+ In versions 1.44 and 1.43 of horde/Prefs/ldap.php, following line was changed:
+
+ ---
+ if (isset($result)) {
+ ---
+
+ to
+
+ ---
+ if (isset($result[0]['hordeprefs'])) {
+ ---
+
+ Now there raises a problem when we get no results from query, it would output
+ some indexes problems again :) (well... kinda unlikely but it is possible). So I
+ would prefer that you revert that change so we will have same sanity checking
+ whether we got anything from query.
+
+ and speaking about sanity checking... I have made patch against HEAD (only
+ tested it against patched horde 2.1 though) that fixes that problem and also
+ makes some corrections to preferences handling (I hope :).
+
+ some notes:
+ - $prefs = array(); removed because contents of array must be array because of
+ checkings in begining of function and this would clear existing prefs. (default
+ prefs?)
+
+ - if we are looking only for hordePrefs we don't need to specify it two times in
+ search.
+
+ - always merge arrays when possible, not replace them instantly.
+
+ patch:
+ Index: ldap.php
+ ===================================================================
+ RCS file: /repository/horde/lib/Prefs/ldap.php,v
+ retrieving revision 1.44
+ diff -u -p -r1.44 ldap.php
+ --- ldap.php 24 Jul 2002 19:54:19 -0000 1.44
+ +++ ldap.php 25 Jul 2002 07:29:18 -0000
+ @@ -338,11 +338,17 @@ class Prefs_ldap extends Prefs {
+ /* Make sure we are connected. */
+ $this->_connect();
+
+ + /* Only get needed fields */
+ + $attrs = array('hordePrefs');
+ + if (strcmp($this->scope, 'horde') != 0) {
+ +
+ array_push($attrs, $this->scope . 'Prefs');
+ + }
+ +
+ /* Search for the multi-valued field containing the array of
+ preferences. */
+ $search = ldap_search($this->connection, $this->params['basedn'],
+ $this->params['uid'] . '=' . $this->user,
+ - array($this->scope . 'Prefs', 'hordePrefs'));
+ + $attrs);
+ if ($search) {
+ $result = ldap_get_entries($this->connection, $search);
+ } else {
+ @@ -352,9 +358,7 @@ class Prefs_ldap extends Prefs {
+ /* ldap_get_entries() converts attribute indexes to lowercase. */
+ $field = strtolower($this->scope . 'prefs');
+
+ - if (isset($result[0]['hordeprefs'])) {
+ - $prefs = array();
+ -
+ + if (isset($result)) {
+ /* Set the requested values in the $this->prefs hash based on
+ the contents of the LDAP result.
+
+ @@ -368,19 +372,18 @@ class Prefs_ldap extends Prefs {
+ server.
+ */
+
+ - /* Merge $this->scope prefs with shared prefs, if necessary. */
+ + /* If hordePrefs was found, merge them as base of prefs */
+ + if (array_key_exists('hordeprefs', $result[0])) {
+ + $prefs = array_merge($prefs,
+ + $result[0]['hordeprefs']);
+ + }
+ +
+ + /* If $this->scope was found, merge it also, this order will
+ + make $this->scope to have higher priority in preferences. */
+ if (strcmp($this->scope, 'horde') != 0) {
+ if (array_key_exists($field, $result[0])) {
+ - $prefs = array_merge($result[0][$field],
+ - $result[0]['hordeprefs']);
+ - } else {
+ - if (isset($result[0]['hordeprefs'])) {
+ - $prefs = $result[0]['hordeprefs'];
+ - }
+ - }
+ - } else {
+ - if (isset($result[0][$field])) {
+ - $prefs = $result[0][$field];
+ + $prefs = array_merge($prefs,
+ + $result[0][$field]);
+ }
+ }
+
+