Roundcube Community Forum

 

1.1.6 - SQL AddressBook - JobTitle disappears

Started by Davis, November 14, 2016, 06:08:02 AM

Previous topic - Next topic

Davis

Hello,

I have hMailServer, Roundcube 1.1.6, IIS 8.5, Win2k12
Suddenly I've realized that several fields of contacts in address book does now shown in roundcube interface.
Main fields works fine: name, surname, phones, emails. Even suffixes and prefixes.
But, for example, jobtitle and department only shown once after fresh logging in. For any contact.
I.e.:
- at morning I log in under my account and open address book
- select ANY contact in book
- in shown contact info all fields visible
- select ANY other contact and there are no jobtitle and department info. Of course this info is in Vcards in SQL table
- I can select first contact again and it also now displayed without jobtitle and department info
After this I may log out/log in - no changes.
Only after some time, I cannot say exactly, I guess it is about 30-60 minutes, something resets and whole path can be reproduced.
I cannot understand what does it depend of.
This happens with personal SQL books and with global SQL book.
This remains with all plug-ins turned off.

Please help me fix this



Davis

Strange thing.
First I've found that changing any php file "resets" this bug and first selected contact shown OK.
Second. In file \program\lib\Roundcube\rcube_vcard.php after line 240 I've added some debug code:
else {
  $out[$key][] = $raw[0];
    if ($key == 'jobtitle') {
      write_log('Davis', '$out['.$key.']=' . print_r($out[$key], true));
      write_log('Davis', '$out[\'jobtitle\']: ' . print_r($out['jobtitle'], true));
    }
}

And after saving this php I select any contact in address book and got this log file:
[18-Nov-2016 17:29:00 +0200]: <vvmuutqp> $out[jobtitle]=Array
(
    [0] => Редактор контента
)

[18-Nov-2016 17:29:00 +0200]: <vvmuutqp> $out['jobtitle']: Array
(
    [0] => Редактор контента
)

[18-Nov-2016 17:29:00 +0200]: <vvmuutqp> $out[jobtitle]=Array
(
    [0] => Редактор контента
)

[18-Nov-2016 17:29:00 +0200]: <vvmuutqp> $out['jobtitle']:


As we can see function get_assoc() called twice. First time both debug commands show correct values for jobtitle.
But second time first debug command printed same value but second - empty value.
$out[$key] sees value but  $out['jobtitle'] - not
How it can be possible??


Davis

Ok next step:
now this code:
$out[$key][] = $raw[0];
if ($key == 'jobtitle') {
write_log('Davis', 'whole $out: ' . print_r($out, true));
$out['jobtitle'][0] = 'Davis:' . $raw[0];
write_log('Davis', 'whole $out after manual set: ' . print_r($out, true));
}

Gives me this amazing result:
[21-Nov-2016 16:15:17 +0300]: <013l7feb> whole $out: Array
(
    [name] => Имя
    [firstname] => Имя
    [surname] => Фамилия
    [phone:work] => Array
        (
            [0] => 123-56-78
        )

    [email:work] => Array
        (
            [0] => [email protected]
        )

    [jobtitle] => Array
        (
            [0] => Должность
        )

)

[21-Nov-2016 16:15:17 +0300]: <013l7feb> whole $out after manual set: Array
(
    [name] => Имя
    [firstname] => Имя
    [surname] => Фамилия
    [phone:work] => Array
        (
            [0] => 123-56-78
        )

    [email:work] => Array
        (
            [0] => [email protected]
        )

    [jobtitle] => Array
        (
            [0] => Должность
        )

    [jobtitle] => Array
        (
            [0] => Davis:Должность
        )

)

As we can see we have two 'jobtitle' keys.
What can be wrong with key value?
It have to be equal to 'jobtitle' both times but looks like it has different values

Davis

I do not know - why but after I've changed
$out[$key][] = $raw[0];
to
$out[trim($key)][] = $raw[0];
jobtitle became visible all time