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

Truncating Poll Responses in the vBulletin => XenForo Importer

Discussion in 'XenForo Development Discussions' started by Chris D, Apr 21, 2013.

  1. Chris D

    Chris D XenForo Developer Staff Member

    My understanding is that the XenForo DataWriter for poll responses has a maxLength set of 100 characters. (As is the database field).

    And if you import from vBulletin and you have responses that exceed that, the import still occurs, but the poll responses seem to be trimmed to an appropriate length.

    Basically I just want to ensure that the vBull => XenForo importer will accept a much larger maxLength for a poll response without it being trimmed to 100 characters.

    1) I will change the maxLength to a much larger number in the PollResponse DataWriter.
    2) I will change the database field to a much larger varchar or text field.

    This is the important bit:
    3) How do I ensure the poll response isn't trimmed? Or is the very fact that the DataWriter will accept a larger value enough?
    Dakis likes this.
  2. AlexT

    AlexT Well-Known Member

    I am using a heavily modified and extended version of the vB 3.8 importer to prepare for my upcoming migration. To make sure poll responses survive the import, I did the following:

    1. Alter Poll Response Table in xF
    ALTER TABLE xf_poll_response
    CHANGE response
            response VARCHAR(120) NOT NULL
    2. in XenForo_Importer_vBulletin::stepPolls

    $responses = explode('|||', $this->_convertToUtf8($poll['options'], true));

    Replace with:

    $responses = explode('|||', XenForo_Helper_String::bbCodeStrip($this->_convertToUtf8($poll['options'], true)));

    (since xF doesn't support BB Codes in poll responses)

    3. Use the attached Import helper add-on, which needs to be installed before you run the import step for polls.

    Attached Files:

    Dakis likes this.
  3. tyteen4a03

    tyteen4a03 Well-Known Member

    Firstly, i c wut u did thar @ vBull

    Back to your question, I believe the data is trimmed the moment you call set (set -> _isFieldValueValid -> _applyFieldValueLimits -> substr), so you can just use get and then compare it to the original value.
  4. Chris D

    Chris D XenForo Developer Staff Member

    Thanks Alex, that's very helpful.

    Something that may interest you, actually, is I've written an add-on that parses BB Code in poll responses.

    So I was already going to do Step 1 and Step 3, but Step 2 won't be necessary for me.

    I think what tyteen4a03 has posted is the clue in the right direction... but if it just bases the limits on the maxLength set in the DataWriter fields list then I may very well be all set :)

    Thanks guys.

    EDIT: Yeah. I just flicked through the _applyFieldValueLimits function and it does exactly that. Trims the value to the amount set in maxLength. So as long as that number is high enough, we should be ok.

    AlexT, what might be useful to know. You've set the value to 120. Is that the poll response limit in vB 3.x?
  5. AlexT

    AlexT Well-Known Member

    There is no hard limit. In vB, poll responses are stored as serialized data in as a delimited string. The limit is defined in Admin CP options under Help Poll and Thread Rating Options -> Poll Option Length. In my case that's 120 (the vB default is 100).

    Since this limit is calculated without counting characters for BB codes, you must take extra space into consideration if you want to keep BB codes in responses. It's why I decided not to take over BB codes - it'd be difficult to predict the minimum required field size for the 'responses' field.
  6. tyteen4a03

    tyteen4a03 Well-Known Member

    That must be why I can't seem to find the relevant data in the database. :p

Share This Page