[horde] Using hooks to permanently set from_addr and fullname

Chuck Hagenbuch chuck at horde.org
Thu Jul 21 12:49:47 PDT 2005


Quoting Kevin Myer <kevin_myer at iu13.org>:

> I have hooks configured to set the preferences of from_addr and fullname from
> our LDAP directory server.  The problem I am having with this config is I'm
> generating lots of extra LDAP lookups - for example, every mail composition
> generates an LDAP search for a name and an address for a sender, and there
> appears to be other places this occurs.  The net result is a ton of LDAP
> connections, either established, or in TIME_WAIT state (25000+) for 
> information that should be looked up at initial login and then saved, 
> or at least cached.

Are you sure this is from preferences hooks? The check on line 707 of 
Prefs.php:

        if (!is_null($this->_hooksCalled) && !Auth::getAuth()) {
            return;
        }

... looks suspicious to me - should that be && Auth::getAuth(), instead 
of ! ? Anyone?

.. but even so, prefs are cached during a session. So unless that 
caching is failing somehow, the hooks should only be called once per 
session - I don't see any place that calls Prefs::_callHooks() outside 
of Prefs::retrieve(), after we return if prefs are found cached.

> How can I optimize this - add caching to my two hooks?  Add a 
> pref->write within the hooks?

If you do a write then the hook will never be called again (i.e., the 
user will have to change it themself from then on). If that's alright 
that'd certainly be an optimization.

-chuck

-- 
"But she goes not abroad in search of monsters to destroy." - John 
Quincy Adams


More information about the horde mailing list