1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed vB 3.8 to XF 1.2 Import: Birthdays without years

Discussion in 'Resolved Bug Reports' started by rellek, Jul 12, 2013.

  1. rellek

    rellek Well-Known Member

    ...are imported as 1900. Although XF seems to accept an empty year. So I think that is a bug?
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    Did you do a double import or was it a direct import?
     
  3. AlexT

    AlexT Well-Known Member

    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.
     
  4. rellek

    rellek Well-Known Member

    @King Kovifor It was a direct import from vB 3.8 to XF 1.2 b3.

    @AlexT
    In the vB database, there is 12-26-0000 and showbirthday is 3 in this case.
     
  5. Jeremy

    Jeremy XenForo Moderator Staff Member

    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?
     
  6. rellek

    rellek Well-Known Member

    That user left the birth year blank. So I think it's save to assume a blank year results in 0000 in the database.
     
  7. AlexT

    AlexT Well-Known Member

    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: Jul 12, 2013
    SneakyDave and rellek like this.
  8. Kier

    Kier XenForo Developer Staff Member

    Fixed, I think :)
     
    Eagle, rellek, TBolley and 1 other person like this.

Share This Page