Roundcube Community Forum

 

Birthdays not stored properly in 0.8.4

Started by grpprod, December 22, 2012, 12:57:15 AM

Previous topic - Next topic

grpprod

Hi,
I am not sure this is an issue (if so please let me know to report it), or if this applies to other addressbook fields as well. I tried to create a contact and specified a birthday. But when using advanced search, it does not display result. To be exact:

Birthday was set to 10/12/2012. When using search, putting '10/12/2012' in the search field shows no result. Putting '10' or '2012' finds the contact properly. Perhaps the date is stored in a specific form?

SKaero

#1
The birthday seems to be formatted as <year>-<day>-<month> like 2012-10-12, the search should be more flexible.

grpprod

IMHO, it does not look good to ask users to perform searches in this way. It wouldn't be too difficult to make the search search using the current date_format.

SKaero

Agreed, a bug report should probably be made but it may have already been fixed it the git version and I don't have the time to test that right now.

grpprod

Would just changing the SQL creation files solve this? I refer to:

QuoteALTER TABLE `identities` ADD `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00' AFTER `user_id`;

CREATE TABLE `contactgroups` (
  `contactgroup_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
  `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',

etc.
If anyone else can confirm if this was fixed in git that would be nice.

JohnDoh

it has not been fixed in git master yet. I have created a ticket with some patches to do the job here http://trac.roundcube.net/ticket/1488888
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

grpprod

#6
in my 0.8.4, there is no program/lib/Roundcube directory. the file you mention is located in program/include, and it does not look the same.

for example, in rcube_vcard.php I can find the following:
Quote
      case 'birthday':
      case 'anniversary':
        if (($val = rcube_strtotime($value)) && ($fn = self::$fieldmap[$field]))

thanks so much anyway. since i am not familiar with this, could you please let me know how to apply the patch. thanks

JohnDoh

#7
you are correct in 0.8.* the files would be in /program/include. I had a look at the old files on git and from what i can see the affected lines are the same. as long as you can read diffs you should be fine. in rcube_contacts you'll need to use


if (is_array($value)) {
    if (($col == 'birthday' || $col == 'anniversary') && $val = rcube_strtotime($val))
        $val = date(rcube_vcard::$date_format, $val);

    $post_search[$col] = mb_strtolower($val);
}


since there is no framework. if you cant then i guess you'll have to wait and see if the devs choose to apply my patch
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

grpprod

#8
Well, I've tried this. However I did not apply the second patch, only the first (format_date_in_abook_search.patch). I also included your correction for 0.8. However now this creates another issue. I did not bother to search yet, because now it alters the date. For example: I created a contact with birthday like the following:

06/12/1982 (DD/MM/YYYY).

When I save the contact, the date is stored as: 12/06/1982. Examining the record, it is stored like this:
BDAY;VALUE=date:1982-06-12

Am I missing something here?
EDIT: I see this is not caused by the patch, because I restored the unpatched files and the behaviour is the same. Perhaps datepicker sends wrong string?

JohnDoh

i think this is a function of php see http://uk3.php.net/manual/en/function.strtotime.php
QuoteDates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

grpprod

It's getting more complex now. Shouldn't this be predicted by RC? I'm kind of lost now. Even if I can't make search work properly, I would expect at least the date to be stored (and shown) as entered. IMHO, this is certainly a bug. This is also proven by the fact that if, for example, we enter a date which is out of bounds in the stored format (for example, if i enter '25/12/1980' nothing will be stored in the contact, because it will first be converted to 1980-25-12' which clearly is invalid.

In any case, is it possible to prohibit datepicker to add slashes? I did not add the slashes, it did.

JohnDoh

you can change the date format in the config - date_format, i'm not sure where else it is used though.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

grpprod

This setting is already utilized. I don't think it is used in this case, though.