[turba] Suggestion for sizelimit

Andrew Morgan morgan at orst.edu
Wed Aug 13 21:01:45 PDT 2003



On Thu, 14 Aug 2003, Jan Schneider wrote:

> Zitat von Andrew Morgan <morgan at orst.edu>:
>
> > I don't have a HEAD installation anywhere, so maybe you can help me with
> > the details.  Here is roughly how it should look:
> >
> >         /* Send the query to the LDAP server and fetch the matching
> > entries. */
> >         if (!($res = @ldap_search($this->ds, $this->root, $filter, $attr,
> > 0, $sizelimit))) {
> >             $this->errno = ldap_errno($this->ds);
> >             $this->errstr = ldap_error($this->ds);
> >             return PEAR::raiseError($this->errstr);
> >         }
> >
> >         if (ldap_errno($this->ds) != 0) {
> >             $notification->push(ldap_error($this->ds));
> >         }
> >
> >         return $this->getResults($fields, $res);
> >
> >
> > I'm just taking a guess at how $notification->push() works...  :)
>
> It would be even as easy as:
>
>         if (!($res = @ldap_search($this->ds, $this->root, $filter, $attr,
> 0, $sizelimit))) {
>             $this->errno = ldap_errno($this->ds);
>             $this->errstr = ldap_error($this->ds);
>             $notification->push($this->errstr, 'horde.error');
>         }
>
> BUT: The fact that $this->errno/errstr gets populated might be a hint that
> these properties get used/displayed elsewhere. This is without looking at
> the actual code. Beside that, if the code is from a library, it should NOT
> display any errors to the user but rather return it (as it does now) to the
> calling script where it gets pushed on the notification stack.

I don't think it can be that simple.  The ldap server will *always* return
an "error" code.  The proper name should be "result" code actually.  If
everything is good, it will be 0.  So we can't automatically push the
errstr onto the notification stack.  Also, if you don't get a result set
back, you want to push the error and return a null array.  But if you do
get a result set back (which you'll get for some errors, include sizelimit
exceeded), you want to display whatever results are available and push the
non-zero error code/string back to the user.

So I think it is still important have a separate if block for the "result
set available but error returned" case.

I'll try to take a look at the code tomorrow to see if $this->errno or
$this->errstr are used anywhere else.  If they are and we don't want to
affect that in the case of a "warning" ldap error, we could just push the
ldap_error into notification and not set $this->errno/str.

	Andy



More information about the turba mailing list