xoops forums

Monika

Not too shy to talk
Posted on: 2009/2/16 11:49
Monika
Monika (Show more)
Not too shy to talk
Posts: 103
Since: 2008/12/19
#1

Profile module date bug, request fix

Hi guys
There is a bug in profile module, it doesn't save the date correctly!

To make it clear, I have created a new field in User Profile, field type: DATE.

I made it required in registration form.

The problem is when someone wants to register, he choose his birthday DATE, but it is not saved during registration!!

He has to go back to his profile and edit the DATE again!! then it will be saved correctly.

Why? and how to fix this?

Anyone of you can test this, it only takes 2 minutes.

Please help, many thanks in advance.

Anonymous

Posted on: 2009/2/21 0:20
Anonymous
Anonymous (Show more)
Posts: 0
Since:
#2

Re: Profile module date bug, request fix

localhost or online ?

Windows does not support date functions in php files.

Monika

Not too shy to talk
Posted on: 2009/2/21 1:03
Monika
Monika (Show more)
Not too shy to talk
Posts: 103
Since: 2008/12/19
#3

Re: Profile module date bug, request fix

both, tested on linux real server.

Catzwolf

Home away from home
Posted on: 2009/3/8 2:24
Catzwolf
Catzwolf (Show more)
Home away from home
Posts: 1392
Since: 2007/9/30
#4

Re: Profile module date bug, request fix

examples of usage that fails to work please?

Monika

Not too shy to talk
Posted on: 2009/3/15 2:15
Monika
Monika (Show more)
Not too shy to talk
Posts: 103
Since: 2008/12/19
#5

Re: Profile module date bug, request fix

Quote:
examples of usage that fails to work please?

Hi sir, please just read my first post carefully, then you will understand me.

Usage : adding a new field (DATE) in profile.

The bug: It will always show the default date whatever the date the memeber chose during his registration.

I hope this is clear

Catzwolf

Home away from home
Posted on: 2009/3/15 13:25
Catzwolf
Catzwolf (Show more)
Home away from home
Posts: 1392
Since: 2007/9/30
#6

Re: Profile module date bug, request fix

Thanks, We just needed to know if this was just the registration or it happened elsewhere.

Catz

Monika

Not too shy to talk
Posted on: 2009/3/19 18:22
Monika
Monika (Show more)
Not too shy to talk
Posts: 103
Since: 2008/12/19
#7

Re: Profile module date bug, request fix

Well I have just tested it on registration. Because my aim was to show members' birth day on their profile. But because of this bug, it only shows the default date whatever the new registred member has selected as a date.



zorro87

Just popping in
Posted on: 2009/3/26 11:16
zorro87
zorro87 (Show more)
Just popping in
Posts: 92
Since: 2006/9/29
#8

Re: Profile module date bug, request fix

Hi!

This is a very interesting problem!

I confirm: You have to go back to the profile to change date and then, the date is saved correctly.

A clue?

Dates are saves as UNIX format
0=1970-01-01

When you first save a date, the date (field date in profile_profile) is saved as a 4 digit number corresponding to the year of the date you selected (ex.“1975” if you chose 1975-03-15 as date).

This date (1975-03-15) should be saved as: 164070000 (UNIX time)

The date was not translated as a UNIX date and
1975 is understood as 1970-01-01 and 1975 seconds (UNIX date)
It is the reason why the date appears as 1970-01-01

With this date format (0 = 1970-01-01) there is a problem:

You can't make a date as mandatory field because default date always exist!
(0 UNIX = 1970-01-01)

Can’t we have date field save in this format 1970-01-01?

It is just a suggestion…
What do you think about that?


@+
Z

trabis

Core Developer
Posted on: 2009/3/26 19:57
trabis
trabis (Show more)
Core Developer
Posts: 2269
Since: 2006/9/1 1
#9

Re: Profile module date bug, request fix

Edit profile/register.php around line 101,

Replace the foreach loop with this:
foreach (array_keys($fields) as $field) {
        if (!isset(
$_POST[$field])) continue;
        
$value $fields[$field]->getValueForSave($_POST[$field]);
        if (
in_array($field$userfields)) {
            
$newuser->setVar($field$value);
        } else {
            
$profile->setVar($field$value);
        }
    }

zorro87

Just popping in
Posted on: 2009/3/27 9:03
zorro87
zorro87 (Show more)
Just popping in
Posts: 92
Since: 2006/9/29
#10

Re: Profile module date bug, request fix

Hi Trabis!

Trabis, you are the best!

This bug is fixed!
Quote:

The problem is when someone wants to register, he choose his birthday DATE, but it is not saved during registration!!

He has to go back to his profile and edit the DATE again!! then it will be saved correctly.


Thank you Trabis!


@+
Z