IPS Poll discrepancies.

Slavik

XenForo moderator
Staff member
Affected version
2.0
On poll imports from IPS we decode the "choices" field from the poll table.

The importer checks the decoded data for the question entry and sets that accordingly:

Code:
$questions = json_decode($poll['choices'], true);

            $question = $stepConfig['which_question'] == 'newest'
                ? end($questions)
                : reset($questions);


 /** @var \XF\Import\Data\Poll $import */
            $import = $this->newHandler('XF:Poll');
            $import->set('question', $question['question']);
            $import->bulkSet([
                'content_type' => 'thread',
                'content_id' => $newThreadId,
                'public_votes' => $poll['poll_view_voters'],
                'max_votes' => empty($question['multi']) ? 1 : 0,
                'close_date' => $poll['poll_close_date'],
            ]);


In some cases, the question is set instead in the "question" field instead which will result in an undefined array error, so an alternate query is needed eg

Code:
            /** @var \XF\Import\Data\Poll $import */
            $import = $this->newHandler('XF:Poll');
            //$import->set('question', $question['question']);
            $import->bulkSet([
                'question' => $poll['poll_question'],
                'content_type' => 'thread',
                'content_id' => $newThreadId,
                'public_votes' => $poll['poll_view_voters'],
                'max_votes' => empty($question['multi']) ? 1 : 0,
                'close_date' => $poll['poll_close_date'],
            ]);

And in same rare cases there is a mix of the two. So it would be ideal to run a check for one then the other to stop an import falling over.
 
Back
Top Bottom