[Tickets #13152] Re: address auto-completion returns all addresses of address book

noreply at bugs.horde.org noreply at bugs.horde.org
Sun May 4 13:35:13 UTC 2014


Ticket URL: http://bugs.horde.org/ticket/13152
  Ticket             | 13152
  Updated By         | jmozdzen at nde.ag
  Summary            | address auto-completion returns all addresses of
                     | address book
  Queue              | IMP
  Version            | 6.1.7
  Type               | Bug
  State              | Feedback
  Priority           | 1. Low
  Milestone          |
  Patch              |
  Owners             |

jmozdzen at nde.ag (2014-05-04 13:35) wrote:

>>> Can't reproduce.  Sounds more like a Turba issue anyway.
>> how should I proceed?
>> a  - can you move this ticket to Turba or do I need to re-open
>> another ticket?
> Once its verified as an issue in Turba, I can move it.
> [...]
> You are going to need to trace the code in Turba (specifically the  
> Turba_Api#search() method) to determine why it is returning all  
> entries.  (Or Horde_Core_Ajax_Imple_ContactAutoCompleter, since  
> that's where the search call is actually made).

to make a long story short: The effect was caused by a "search_fields"  
hook for IMP (I included that from the original Kolab client - that's  
why it slipped by). I don't understand why this happens, though.

In my IMP prefs.d/10-Kolab.php file I had  set  
"$_prefs['search_fields']['hook'] = true;" and hooks.php read

--- cut here ---
     public function prefs_init($pref, $value, $username, $scope_ob)
         switch ($pref) {
         case 'add_source':
             // Dynamically set the add_source preference.
             return is_null($username)
                 ? $value
                 : $GLOBALS['registry']->call('contacts/getDefaultShare');

         case 'search_fields':
         case 'search_sources':
             // Dynamically set the search_fields/search_sources preferences.
             if (!is_null($username)) {
                 $sources = $GLOBALS['registry']->call('contacts/sources');

                 if ($pref == 'search_fields') {
                     $out = array();
                     foreach (array_keys($sources) as $source) {
                         $out[$source] =  
                 } else {
                     $out = array_keys($sources);

                 return json_encode($out);

             return $value;
--- cut here ---
This probably is some "old-style stuff" - hooks aren't my cup of tea  
(yet), I included them from the original kolab-webmail package. During  
my initial debugging of this issue, I went through the following steps:

I've added according debug statements and see that   
$hordedir/imp/lib/Contacts.php:getAddressbookSearchParams() does  
return a huge set of search fields after a fresh login, but no search  
fields at all once I opened and saved IMP's "user  
prefs/webmail/address books" (WITHOUT CHANGING ANY PREF!)

I have attached a debug trace of the following code there:

--- cut here ---
     public function getAddressbookSearchParams()
         global $prefs;

         $fields = json_decode($prefs->getValue('search_fields'), true);

         Horde::debug( $fields);

         $src = json_decode($prefs->getValue('search_sources'));

         return array(
             'fields' => empty($fields) ? array() : $fields,
             'sources' => empty($src) ? array() : $src
--- cut here ---

The first backtrace is generated before the settings were saved, the  
second backtrace (-> empty $fields) after saving the IMP/webmail  
address book preferences (without modifying any setting!).

Looking at the user's preference page (Webmail/address books), when I  
loop through the address books that are in the list of ABs to be  
searched, it's always "name" and "email addresses" that's set as  
search fields for user address books, it's "email addresses" for "most  
commonly used receivers" and it's the full set of fields for "global  
address book".

I've tried to reduce the list of searched fields for the global  
address book - this setting is not stored across logins. (I selected  
"name, surname, emails", saved the settings and verified they were the  
same, then logged off/on and again all fields were selected). This  
points to the user preference handling... at this point, I made the  
link to probably set hooks and looked it up. Once I disabled the  
"search_fields" hook, everything was working correctly.

Maybe you might want to move this ticket to the Kolab queue?


PS: Something else that does catch the eye are hundreds of messages

--- cut here ---
2014-05-04T14:22:53+02:00 WARN: HORDE [turba] PHP ERROR: stripos()  
expects parameter 1 to be string, array given [pid 5743 on line 536 of  
--- cut here ---
in Horde's log file. These messages are created while the search Ajax  
call is executed, but only for those calles before the settings were  
saved. I've created a separate ticket  
(http://bugs.horde.org/ticket/13161) and do not thing this issue is  
related, because if I disable searching array fields (I our case,  
seems it's only the field "categories") temporarily, the result lists  
are still the same.

More information about the bugs mailing list