6.0.0-beta1
7/19/25

[#12272] Search-all and strict fields
Summary Search-all and strict fields
Queue Turba
Queue Version Git master
Type Bug
State Resolved
Priority 2. Medium
Owners jan (at) horde (dot) org
Requester kd (at) tu-cottbus (dot) de
Created 05/24/2013 (4439 days ago)
Due
Updated 10/20/2017 (2829 days ago)
Assigned
Resolved 01/19/2016 (3469 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch Yes

History
10/20/2017 08:34:43 PM Git Commit Comment #9 Reply to this comment
Changes have been made in Git (FRAMEWORK_5_2):

commit a1c47e4c863fb3e10db48fb07f439e0501fb58a0
Author: Jan Schneider <jan@horde.org>
Date:   Tue, 19 Jan 2016 11:59:10 +0100

[jan] Fix building search query if some fields are set for strict 
search (Bug #12272).

  M docs/CHANGES
  M package.xml

https://github.com/horde/turba/commit/a1c47e4c863fb3e10db48fb07f439e0501fb58a0
10/20/2017 08:34:42 PM Git Commit Comment #8 Reply to this comment
Changes have been made in Git (FRAMEWORK_5_2):

commit 28eafb530af4d5b0f6ea9bbf6de45519dfe1619c
Author: Jan Schneider <jan@horde.org>
Date:   Tue, 19 Jan 2016 11:59:03 +0100

Fix building search query if some fields are set for strict search 
(Bug #12272).

  M lib/Driver.php

https://github.com/horde/turba/commit/28eafb530af4d5b0f6ea9bbf6de45519dfe1619c
01/19/2016 05:52:11 PM Git Commit Comment #7 Reply to this comment
Changes have been made in Git (master):

commit 2fcc71ae6541bf54a63ee7f50c3115249d0c1983
Author: Jan Schneider <jan@horde.org>
Date:   Tue Jan 19 11:59:10 2016 +0100

     [jan] Fix building search query if some fields are set for strict 
search (Bug #12272).

  turba/package.xml |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)

http://github.com/horde/horde/commit/2fcc71ae6541bf54a63ee7f50c3115249d0c1983
01/19/2016 10:59:22 AM Git Commit Comment #6 Reply to this comment
Changes have been made in Git (FRAMEWORK_5_2):

commit a56dce2b13a4e8183cc13301a1bb751fa27ce4d6
Author: Jan Schneider <jan@horde.org>
Date:   Tue Jan 19 11:59:10 2016 +0100

     [jan] Fix building search query if some fields are set for strict 
search (Bug #12272).

  turba/docs/CHANGES |    2 ++
  turba/package.xml  |    2 ++
  2 files changed, 4 insertions(+), 0 deletions(-)

http://github.com/horde/horde/commit/a56dce2b13a4e8183cc13301a1bb751fa27ce4d6
01/19/2016 10:59:19 AM Git Commit Comment #5 Reply to this comment
Changes have been made in Git (FRAMEWORK_5_2):

commit a8fd4ca65eaf7ca19494a5337a68a550ff0c6586
Author: Jan Schneider <jan@horde.org>
Date:   Tue Jan 19 11:55:59 2016 +0100

     Fix building search query if some fields are set for strict 
search (Bug #12272).

  turba/lib/Driver.php |   20 ++++++++++++++------
  1 files changed, 14 insertions(+), 6 deletions(-)

http://github.com/horde/horde/commit/a8fd4ca65eaf7ca19494a5337a68a550ff0c6586
01/19/2016 10:56:25 AM Jan Schneider Comment #4
Assigned to Jan Schneider
Version ⇒ Git master
State ⇒ Resolved
Reply to this comment
It's even a bit simpler.
01/19/2016 10:56:17 AM Git Commit Comment #3 Reply to this comment
Changes have been made in Git (master):

commit 62024a5ec9463e8560ce670c2205ba404b5e559e
Author: Jan Schneider <jan@horde.org>
Date:   Tue Jan 19 11:55:59 2016 +0100

     Fix building search query if some fields are set for strict 
search (Bug #12272).

  turba/lib/Driver.php |   20 ++++++++++++++------
  1 files changed, 14 insertions(+), 6 deletions(-)

http://github.com/horde/horde/commit/62024a5ec9463e8560ce670c2205ba404b5e559e
05/24/2013 01:02:24 PM kd (at) tu-cottbus (dot) de Comment #2
New Attachment: Driver.php.patch Download
Reply to this comment
here is the patch.
05/24/2013 12:59:32 PM kd (at) tu-cottbus (dot) de Comment #1
Priority ⇒ 2. Medium
State ⇒ Unconfirmed
Patch ⇒ Yes
Milestone ⇒
Queue ⇒ Turba
Summary ⇒ Search-all and strict fields
Type ⇒ Bug
Reply to this comment
If in the default sql addressbook an additional field is declared as 
strict, the resulting sql-statement
is wrong. Add for example object_email to the strict-array and do a 
search-all for a valid email.

All -> a@b.c.d

This results in the following query:
         SELECT object_id, owner_id, object_type, object_members, object_uid,
           object_firstname, object_lastname, object_middlenames,
           object_nameprefix, object_namesuffix, object_alias, object_bday,
           object_photo, object_phototype, object_homestreet, object_homepob,
           object_homecity, object_homeprovince, object_homepostalcode,
           object_homecountry, object_workstreet, object_workpob,
           object_workcity, object_workprovince, object_workpostalcode,
           object_workcountry, object_tz, object_email, object_homephone,
           object_workphone, object_cellphone, object_fax, object_pager,
           object_title, object_role, object_company, object_logo,
           object_logotype, object_category, object_notes, object_url,
           object_freebusyurl, object_pgppublickey, object_smimepublickey FROM
           turba_objects WHERE (object_email = 'a@b.c.d' OR owner_id = 'kd' AND
           ((LOWER(object_nameprefix) LIKE LOWER('%a@b.c.d%') OR
           LOWER(object_firstname) LIKE LOWER('%a@b.c.d%') OR
           LOWER(object_middlenames) LIKE LOWER('%a@b.c.d%') OR
           LOWER(object_lastname) LIKE LOWER('%a@b.c.d%') OR
           LOWER(object_namesuffix) LIKE LOWER('%a@b.c.d%'))))

This is wrong.
I believe, this is caused by always adding "owner_id = user" as a 
strict search (in Driver.php - search).
It can be solved by "anding" the  "owner_id = user" _after_ the search 
is build (makeSearch).
A possible patch is attached.
Probably this is related to Bug #12089.

Saved Queries