[#6039] contact search box rendered PHP error
Summary contact search box rendered PHP error
Queue Kolab
Type Bug
State Resolved
Priority 2. Medium
Owners Gunnar Wrobel <p (at) rdus (dot) de>
Requester m (dot) gabriel (at) das-netzwerkteam (dot) de
Created 12/24/2007 (333 days ago)
Due
Updated 03/20/2008 (246 days ago)
Assigned 12/24/2007 (333 days ago)
Resolved 03/20/2008 (246 days ago)
Attachments field+needle.patch Download
field+needle2.patch Download
Milestone
Patch No

History
03/20/2008 m (dot) gabriel (at) das-netzwerkteam (dot) de Comment #5 Reply to this comment
Thanks for the patches. I did commit something more elaborate now
since searching in the Kolab driver was really horribly broken.

I'll close this one now but please reopen if testing shows further
problems in the new version.
symptomatics have improved tremendously!!!

thx,
mike
03/20/2008 Gunnar Wrobel Comment #4
State ⇒ Resolved
Reply to this comment
Thanks for the patches. I did commit something more elaborate now 
since searching in the Kolab driver was really horribly broken.

I'll close this one now but please reopen if testing shows further 
problems in the new version.
12/25/2007 m (dot) gabriel (at) das-netzwerkteam (dot) de Comment #3
New Attachment: field+needle2.patch Download
Reply to this comment
another error in the _search method of the 
Turba_Driver_kolab_wrapper_new class...

the application context is already described in ticket #6046 occurred 
(i a nutshell: i tried to add a CSV address book: LASTNAME, FIRSTNAME, 
EMAIL).

on import the following php error is rendered:

Notice: Undefined index: last-name in 
/usr/local/share/_horde-versions_/horde-webmail-1.1-rc1-netzwerkteam/turba/lib/Driver/kolab.php on line 
775

this happens if the CSV contains lines like the third line in the 
following example:

<snip csv-file>
Lastname, Firstname, eMail
Gabriel, Mike, user@mail.test
Onlylastname,,lastname@mail.test
</snip>

so i tuned up the _search method a little more... (patch also attached)...

grimnir:/usr/local/share/_horde-versions_# diff -u 
/usr/local/share/_horde-versions_/horde-webmail-1.1-rc1/turba/lib/Driver/kolab.php 
/usr/local/share/_horde-versions_/horde-webmail-1.1-rc1-netzwerkteam/turba/lib/Driver/kolab.php
--- 
/usr/local/share/_horde-versions_/horde-webmail-1.1-rc1/turba/lib/Driver/kolab.php  2007-11-29 12:32:57.000000000 
+0000
+++ 
/usr/local/share/_horde-versions_/horde-webmail-1.1-rc1-netzwerkteam/turba/lib/Driver/kolab.php     2007-12-25 20:31:48.000000000 
+0000
@@ -764,12 +764,15 @@
                          $all_matched = true;

                          foreach ($tests as $test) {
-                            $field = $test['field'];
-                            $needle = $test['test'];
-
+
+                            $field = '';
+                            $needle = '';
+                            if (isset($test['field'])) { $field = 
$test['field']; }
+                            if (isset($test['test'])) { $needle = 
$test['test']; }
+
                              if (empty($needle)) {
                                  $keep_entry = true;
-                            } elseif (stristr($entry[$field], 
$needle) !== false) {
+                            } elseif (isset($entry[$field]) && 
(stristr($entry[$field], $needle) !== false)) {
                                  $keep_entry = true;
                              } else {
                                  $all_matched = false;

12/25/2007 m (dot) gabriel (at) das-netzwerkteam (dot) de Comment #2
New Attachment: field+needle.patch Download
Reply to this comment
please refer to this patch instead, the former one caused more trouble 
than anything and is rather python than php style...

grimnir:/usr/local/share/_horde-versions_# diff -u 
/usr/local/share/_horde-versions_/horde-webmail-1.1-rc1/turba/lib/Driver/kolab.php 
/usr/local/share/_horde-versions_/horde-webmail-1.1-rc1-netzwerkteam/turba/lib/Driver/kolab.php
--- 
/usr/local/share/_horde-versions_/horde-webmail-1.1-rc1/turba/lib/Driver/kolab.php  2007-11-29 12:32:57.000000000 
+0000
+++ 
/usr/local/share/_horde-versions_/horde-webmail-1.1-rc1-netzwerkteam/turba/lib/Driver/kolab.php     2007-12-25 20:09:21.000000000 
+0000
@@ -764,8 +764,11 @@
                          $all_matched = true;

                          foreach ($tests as $test) {
-                            $field = $test['field'];
-                            $needle = $test['test'];
+
+                            $field = '';
+                            $needle = '';
+                            if (isset($test['field'])) { $field = 
$test['field']; }
+                            if (isset($test['test'])) { $needle = 
$test['test']; }

                              if (empty($needle)) {
                                  $keep_entry = true;

12/24/2007 Chuck Hagenbuch State ⇒ Assigned
Assigned to Gunnar Wrobel
 
12/24/2007 m (dot) gabriel (at) das-netzwerkteam (dot) de Comment #1
Queue ⇒ Kolab
Summary ⇒ contact search box rendered PHP error
Type ⇒ Bug
Priority ⇒ 2. Medium
State ⇒ Unconfirmed
Reply to this comment
i am using kolab-2.1 (debian unstable) and horde-webmail-1.1rc1

when i began to setup my portal i did not import kolab's global 
address book. at that time  the portal block for contact search 
rendered a php-error (that i unfortunately cannot reproduce any more) 
in case the kolab user address book was empty. the patch below fixed 
the problem...

$ diff horde-webmail-1.1-rc1/turba/lib/Driver/kolab.php 
horde-webmail-1.1-rc1-netzwerkteam/turba/lib/Driver/kolab.php
767,768c767,771
<                             $field = $test['field'];
<                             $needle = $test['test'];
---


                           $field = isset($test['field']) and 
$test['field'] or '';
                           $needle = isset($test['test']) and 
$test['test'] or '';
                           #$field = $test['field'];
                           #$needle = $test['test'];