6.0.0-beta1
7/4/25

[#13152] address auto-completion returns all addresses of address book
Summary address auto-completion returns all addresses of address book
Queue IMP
Queue Version 6.1.7
Type Bug
State Not A Bug
Priority 1. Low
Owners
Requester jmozdzen (at) nde (dot) ag
Created 04/30/2014 (4083 days ago)
Due
Updated 05/13/2014 (4070 days ago)
Assigned 04/30/2014 (4083 days ago)
Resolved 05/13/2014 (4070 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
05/13/2014 06:32:23 AM Michael Slusarz Comment #6
State ⇒ Not A Bug
Reply to this comment
That's not an accurate/up-to-date search_fields configuration for the 
prefs_init hook.
05/04/2014 01:35:13 PM jmozdzen (at) nde (dot) ag Comment #5 Reply to this comment

[Show Quoted Text - 13 lines]
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] = 
array_keys($GLOBALS['registry']->call('contacts/fields', 
array($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);

/* JUM DEBUG */
         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?

Regards,
Jens

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 
"/srv/www/htdocs.www.nde.ag.ssl/horde/turba/lib/Driver/Kolab.php"]
--- 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.
05/03/2014 04:00:48 AM Michael Slusarz Comment #4 Reply to this comment
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.
b - I'm again willing to debug on my end, but again could use a helping hand:

What I see is a POST request 
"https://myserver.com/horde/services/ajax.php/horde/imple?token=sometoken&app=imp&imple=IMP_Ajax_Imple_ContactAutoCompleter&input=to&to=Angl" (obviously, I typed in "Angl"), and a  return with 820 addresses.... much more that the 50 that are given as default for 
""...

This seems to be a server-side thing.
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).
05/01/2014 02:51:29 PM jmozdzen (at) nde (dot) ag Comment #3 Reply to this comment
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?

b - I'm again willing to debug on my end, but again could use a helping hand:

What I see is a POST request 
"https://myserver.com/horde/services/ajax.php/horde/imple?token=sometoken&app=imp&imple=IMP_Ajax_Imple_ContactAutoCompleter&input=to&to=Angl" (obviously, I typed in "Angl"), and a  return with 820 addresses.... much more that the 50 that are given as default for 
""...

This seems to be a server-side thing: Initially, I get the complete 
list (no matter how the user preference is set), once I save the user 
preference, I get only the matching results reported via AJAX - no 
matter how I set the value of the "return all contacts" preference or 
how often I set it (test: one tab with "new mail" dialog, on tab open 
with the webmail user preference - I toggle the pref, save, then enter 
some chars in the "to" field of the new message. The ALAX call gets 
sent and returns all matches, no matter what preference I just set).

What file should I look at? The entry point seems to be IMP, I feel I 
should debug whether the autocomplete handler sees that user 
preference value and if so, where it comes from. 
lib/Ajax/Imple/ContactAutoCompleter.php seemed to be the right place - 
but it wasn't obvious to me that this actually contains the code to 
handle the AJAX call?

Regards,
Jens
04/30/2014 09:47:55 PM Michael Slusarz Comment #2
Priority ⇒ 1. Low
State ⇒ Feedback
Reply to this comment
Can't reproduce.  Sounds more like a Turba issue anyway.
04/30/2014 09:28:09 AM jmozdzen (at) nde (dot) ag Comment #1
Priority ⇒ 2. Medium
Type ⇒ Bug
Summary ⇒ address auto-completion returns all addresses of address book
Queue ⇒ IMP
Milestone ⇒
Patch ⇒ No
State ⇒ Unconfirmed
Reply to this comment
Using Horde (latest PEAR as of today),dynamic view. Kolab back-end, 
browser is Firefox 26.0 / Linux

Every time I  log in to Horde: When creating a new mail, 
auto-completing of the address field will return *all* addresses of 
the database, not only the matching entries. Matching entries are 
highlighted, but can easily get lot in the long list of results.

This happens no matter how the user setting "webmail/create new 
message/address book/show all contacts" is set (checked/unchecked). 
Toggling that setting (even if from unchecked to checked) and saving 
the settings will make future actions return only the matching 
entries... until I log in the next time - I will again get the full 
list of addresses, no matter how that setting is set.

Repeatable 100%.

Saved Queries