roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.88k stars 1.64k forks source link

Contacts search does not work with addressbook_search_mods set to an empty array #7974

Closed thisisusernameforgithub closed 3 years ago

thisisusernameforgithub commented 3 years ago

this problem is a continuation of the closed problem #7782

@alecpl hi, i checked in the table the addressbook_search_mods parameters of the user with this problem

"addressbook_search_mods"; a: 0: {}

I think there is something missing here, because other users after addressbook_search_mods have data such as:

"addressbook_search_mods"; a: 5: {s: 4: "name"; i: 1; s: 9: "firstname"; i: 1; s: 7: "**surname**"; i: 1; s: 5: "email"; i: 1; s: 1: "*"; i: 1;}

could this be the case and how can I fix it correctly?

alecpl commented 3 years ago

So, the option is set to an empty array. You could try if resetting the option will help.

bin/moduserprefs.sh --delete --user=<id> addressbook_search_mods

alecpl commented 3 years ago

I cut irrelevant parts ;)

thisisusernameforgithub commented 3 years ago

I cut irrelevant parts ;)

thanks for your reply! in my case - 172 is the user ID, right? 172 171 2021-03-10 13: 56: 33.805615 + 03 0 1 Ivanov Ivan ivanov@domain.ru

and can I perform this operation bin/moduserprefs.sh --delete --user=<id> addressbook_search_mods

without stopping the application and the database? will she bring me nothing bad?)

alecpl commented 3 years ago

Yes. Yes. Yes. You can do a DB backup if you're afraid.

thisisusernameforgithub commented 3 years ago

Yes. Yes. Yes. You can do a DB backup if you're afraid.

user id 171. I executed the command you suggested, in response I received the following:

./moduserprefs.sh --delete --user=171 addressbook_search_mods
Updating prefs for user 171...nothing changed.

compared the changes after this command - everything remained the same ... "addressbook_search_mods"; a: 0: {}

alecpl commented 3 years ago

I think it is already fixed in git-master. A patch for 1.4.x would be this:

--- a/program/steps/addressbook/search.inc
+++ b/program/steps/addressbook/search.inc
@@ -114,13 +114,13 @@ function rcmail_contact_search()
     // quick-search
     else {
         $search = trim(rcube_utils::get_input_value('_q', rcube_utils::INPUT_GET, true));
-        $fields = explode(',', rcube_utils::get_input_value('_headers', rcube_utils::INPUT_GET));
+        $fields = rcube_utils::get_input_value('_headers', rcube_utils::INPUT_GET);

         if (empty($fields)) {
             $fields = array_keys($SEARCH_MODS_DEFAULT);
         }
         else {
-            $fields = array_filter($fields);
+            $fields = array_filter(explode(',', $fields));
         }

         // update search_mods setting

BTW, the command works for me.

thisisusernameforgithub commented 3 years ago

I think it is already fixed in git-master. A patch for 1.4.x would be this:

--- a/program/steps/addressbook/search.inc
+++ b/program/steps/addressbook/search.inc
@@ -114,13 +114,13 @@ function rcmail_contact_search()
     // quick-search
     else {
         $search = trim(rcube_utils::get_input_value('_q', rcube_utils::INPUT_GET, true));
-        $fields = explode(',', rcube_utils::get_input_value('_headers', rcube_utils::INPUT_GET));
+        $fields = rcube_utils::get_input_value('_headers', rcube_utils::INPUT_GET);

         if (empty($fields)) {
             $fields = array_keys($SEARCH_MODS_DEFAULT);
         }
         else {
-            $fields = array_filter($fields);
+            $fields = array_filter(explode(',', $fields));
         }

         // update search_mods setting

BTW, the command works for me.

thanks for your reply! I now have a roundcube version 1.4.9. will this be fixed in the next patch?

alecpl commented 3 years ago

The patch is so simple. Just apply it and check for yourself. Don't waste time waiting for the next patch release without even knowing it fixes the issue for you.

thisisusernameforgithub commented 3 years ago

The patch is so simple. Just apply it and check for yourself. Don't waste time waiting for the next patch release without even knowing it fixes the issue for you.

but how I can apply that patch?

thisisusernameforgithub commented 3 years ago

The patch is so simple. Just apply it and check for yourself. Don't waste time waiting for the next patch release without even knowing it fixes the issue for you.

I apologize for another question: As I understand, to apply this patch, I have to manually replace the specified lines with new ones in /roundcubemail/program/steps/addressbook/search.inc and then the problem with finding contacts in the LDAP address book will be fixed for some employees?

  1. Do I need to execute bin/moduserprefs.sh --delete --user = <id> addressbook_search_mods after these changes?
  2. Do I need to restart the web server after these changes to apply the patches?
alecpl commented 3 years ago

As I understand, to apply this patch, I have to manually replace the specified lines with new ones in /roundcubemail/program/steps/addressbook/search.inc and then the problem with finding contacts in the LDAP address book will be fixed for some employees?

Yes. Supposedly.

1. Do I need to execute `bin/moduserprefs.sh --delete --user = <id> addressbook_search_mods` after these changes?

This is instead of the patch, but you said it didn't work. Maybe because you wrote it this way. There must be no spaces between --user, = and id!

2. Do I need to restart the web server after these changes to apply the patches?

Usually no.

thisisusernameforgithub commented 3 years ago

As I understand, to apply this patch, I have to manually replace the specified lines with new ones in /roundcubemail/program/steps/addressbook/search.inc and then the problem with finding contacts in the LDAP address book will be fixed for some employees?

Yes. Supposedly.

1. Do I need to execute `bin/moduserprefs.sh --delete --user = <id> addressbook_search_mods` after these changes?

This is instead of the patch, but you said it didn't work. Maybe because you wrote it this way. There must be no spaces between --user, = and id!

2. Do I need to restart the web server after these changes to apply the patches?

Usually no.

thanks a lot for the help, changing the lines in /roundcubemail/program/steps/addressbook/search.inc as per your recommendations helped

search in the address book is working. I didn't even have to restart the web server

alecpl commented 3 years ago

Patch applied into the release-1.4 branch. Fixed.