Fixed vB 3.8 to XF 1.2 Import: Birthdays without years

That's strange. Birthdays from vB are imported by these lines of code:

PHP:
        if ($user['birthday'])
        {
            $parts = explode('-', $user['birthday']);
            if (count($parts) == 3)
            {
                $import['dob_day'] = $parts[1];
                $import['dob_month'] = $parts[0];
                $import['dob_year'] = $parts[2];
            }
        }

That should be right and it's working for me. Could you check how birthdays were stored in your vB installation? They should be in the form "06-15-1967" (month-day-year) in the user.birthday table.
 
This looks to be more of a source issue than an import issue. Do any of your users have a birthday that isn't -0000 in vBulletin?
 
That user left the birth year blank. So I think it's save to assume a blank year results in 0000 in the database.
 
You're right - it's a bug. In xF, if the year is not set, it is stored internally as 0 (in xf_user_profile.dob_year). If a year string is given, however, and if that year is '0000', the year will be set to '1900' by the User DataWriter Importer model:

PHP:
        if (!empty($info['dob_year']) && $info['dob_year'] < 1900)
        {
            $info['dob_year'] = 1900;
        }

To fix this issue, the importer should specifically look if the string '0000' is given in the source and set dob_year to an empty element accordingly. For example (untested).

PHP:
        if ($user['birthday'])
        {
            $parts = explode('-', $user['birthday']);
            if (count($parts) == 3)
            {
                $import['dob_day'] = $parts[1];
                $import['dob_month'] = $parts[0];
                $import['dob_year'] = ($parts[2] == '0000') ? '' : $parts[2];
            }
        }
 
Last edited:
Top Bottom