Advertisement:

Author Topic: Converting poll options  (Read 11038 times)

Offline cdesseno

  • Newbie
  • *
  • Posts: 9
Converting poll options
« on: January 20, 2012, 10:47:30 AM »
I am having some troubles converting vBulletin 3.8 to SMF 2.0 with 3.7 converter. All is working fine except* from this:
Quote
Converting poll options...Wrong value type sent to the database. Integer expected. (votes).

* Changing
Code: [Select]
SELECT pollid AS id_poll, options, votes
FROM {$from_prefix}poll;
to
Code: [Select]
SELECT pollid AS id_poll, options, IFNULL(votes, 0)
FROM {$from_prefix}poll;
I managed to skip that bug, but obviously poll are not being imported ok.
hxxp:cdesseno.com.ar [nonactive] - hxxp:forogamers.com.ar [nonactive]

Offline Oldiesmann

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,868
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • https://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Converting poll options
« Reply #1 on: January 20, 2012, 11:46:35 AM »
What happens to the poll options after you make that change? Are they just not being imported at all?
Michael Eshom
Cincy Space - now open!

Offline cdesseno

  • Newbie
  • *
  • Posts: 9
Re: Converting poll options
« Reply #2 on: January 20, 2012, 04:17:48 PM »
As you can see in the image, votes are always zero. Also, another strange thing is that the first letter of label was removed in each row.

hxxp:imageshack.us/photo/my-images/3/screenshotat20120120180.png [nonactive]
hxxp:cdesseno.com.ar [nonactive] - hxxp:forogamers.com.ar [nonactive]

Offline Oldiesmann

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,868
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • https://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Converting poll options
« Reply #3 on: January 21, 2012, 01:50:00 PM »
How does vB store vote info for poll options?

We can figure out the issue with the first letter getting cut off later...
Michael Eshom
Cincy Space - now open!

Offline cdesseno

  • Newbie
  • *
  • Posts: 9
Re: Converting poll options
« Reply #4 on: January 21, 2012, 02:07:56 PM »
Options are stored all in the same field with this format:
Yes|||No|||May be

hxxp:imageshack.us/photo/my-images/850/screenshotat20120121160.png/ [nonactive]
hxxp:cdesseno.com.ar [nonactive] - hxxp:forogamers.com.ar [nonactive]

Offline Oldiesmann

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,868
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • https://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Converting poll options
« Reply #5 on: January 21, 2012, 03:55:05 PM »
I'm honestly not sure what the problem is with the votes.

This is the code SMF uses to get poll options and votes:

Code: [Select]
$ignore = true;
$no_add = true;
$keys = array('id_poll', 'id_choice', 'label', 'votes');

$options = explode('|||', $row['options']);
$votes = explode('|||', $row['votes']);

$id_poll = $row['id_poll'];
for ($i = 0, $n = count($options); $i < $n; $i++)
{
$rows[] = array(
'id_poll' => $id_poll,
'id_choice' => ($i + 1),
'label' => substr(addslashes($options[$i]), 1, 255),
'votes' => (is_numeric($votes[$i]) ? $votes[$i] : 0),
);
}

The only problem I see is with the label - that "1" should be a "0" instead.

SMF sets it to 0 automatically if the value isn't numeric, so the IFNULL shouldn't make any difference.
Michael Eshom
Cincy Space - now open!

Offline cdesseno

  • Newbie
  • *
  • Posts: 9
Re: Converting poll options
« Reply #6 on: January 21, 2012, 04:53:12 PM »
You were right with the label issue! (it is strange that nobody had noticed this bug before).
With the votes problem I think it should be solved with this:
Code: [Select]
SELECT pollid AS id_poll, options, IFNULL( votes, 0 )[b] as votes[/b]
FROM foro_poll

Is there any easy way just to run the poll's section of the converter?
hxxp:cdesseno.com.ar [nonactive] - hxxp:forogamers.com.ar [nonactive]

Offline cdesseno

  • Newbie
  • *
  • Posts: 9
Re: Converting poll options
« Reply #7 on: January 22, 2012, 06:31:20 PM »
Here is the diff with my working version:

Code: [Select]
< 'label' => substr(addslashes($options[$i]), 1, 255),
< 'votes' => (is_numeric($votes[$i]) ? $votes[$i] : 0),
---
> 'label' => substr(addslashes($options[$i]), 0, 255),
> 'votes' => (int) $votes[$i],
hxxp:cdesseno.com.ar [nonactive] - hxxp:forogamers.com.ar [nonactive]

Offline Oldiesmann

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,868
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • https://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Converting poll options
« Reply #8 on: January 25, 2012, 12:52:25 PM »
Did that fix the issue then?
Michael Eshom
Cincy Space - now open!

Offline cdesseno

  • Newbie
  • *
  • Posts: 9
Re: Converting poll options
« Reply #9 on: January 25, 2012, 01:34:16 PM »
Yes!
hxxp:cdesseno.com.ar [nonactive] - hxxp:forogamers.com.ar [nonactive]

Offline Oldiesmann

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,868
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • https://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Converting poll options
« Reply #10 on: January 25, 2012, 01:44:20 PM »
Ok. Thanks for the info. I'll let the developers know so they can get the converter updated :)
Michael Eshom
Cincy Space - now open!