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

Partial Fix Importing Profile Fields

Discussion in 'Resolved Bug Reports' started by EasyTarget, Oct 13, 2011.

  1. EasyTarget

    EasyTarget Well-Known Member

    vb table profilefield, field data has collation of latin1_swedish_ci.

    If using non-latin letters in the profilefield.data field, unserialize will generate a php error.

    And fail to import the profile fields.

    Sample data listed:

  2. Mike

    Mike XenForo Developer Staff Member

    Generally this indicates that the data itself was corrupted, or you haven't fully mimic'd the collation setup you had in vBulletin (specifically the connection character set). If your data is getting converted from latin1 to utf8 by MySQL due to the connection character set, that will break things.

    That said, I have suppressed this error like in private messages, but I suspect your issue is down to the connection character set. (Which should probably be forced to latin1)
  3. EasyTarget

    EasyTarget Well-Known Member

    The database has been moved from multiple servers. The current connection uses utf8 to better support multiple languages. Originally, before my time. it was on latin1. Unserialize doesn't handle mixed charsets well.

    Since the destination field is utf8, maybe a solution could be the following:

    protected function _convertUserFieldChoices(array $profileField, array &$fieldChoiceLookups)
    $choices = array();
    $profileField['data'] = $this->_convertToUtf8($profileField['data']);

            foreach (
    unserialize($profileField['data']) AS $key => $choice)
    // $choice = $this->_convertToUtf8($choice);  // save dozens of fx calls that we don't need.
    $choiceId XenForo_Helper_String::wholeWordTrim($choice230'');
  4. EasyTarget

    EasyTarget Well-Known Member

    If anyone else runs into data conversion issues when importing into XF from another forum, I wrote a more complete conversion function. Send me a message and I can email the functions to you, since it most likely has limited appeal to most forum owners here.

    The function will improve the import speed by minimizing function calls and isn't reliant on having the mb_detect_encoding function available. Additionally you can tailor it to your specific forum needs.

    Fuhrmann likes this.

Share This Page