News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

converter fails on moved topics with shadows

Started by kakaroto, January 02, 2010, 03:23:13 PM

Previous topic - Next topic

kakaroto

Hi,

I've been having some issues trying to convert from phpbb2 to SMF.. I found out the issue to be similar to :
http://www.simplemachines.org/community/index.php?topic=338644.msg2286212#msg2286212
http://www.simplemachines.org/community/index.php?topic=313558.msg2080554#msg2080554
and more interestingly : http://www.simplemachines.org/community/index.php?topic=260688.20
The convert script errors out at recalculating statistics, this is caused if in the same forum (board id) you have two threads that get moved to another forum, and the "leave shadow copy" is enabled. so it should be easy to reproduce...
I've checked the issue and here are my conclusions :

in phpBB, when you move the thread (with shadow copy), it stays in the DB, a new thread is created, all the posts in it get reassigned to the new thread, and the topic_moved_id column in the DB gets set to the new thread id.
Now the convert script copies all the threads, then when it tries to find the id of the first/last message on that thread, it doesn't find any, so it sets it to the empty string "".

UPDATE `smf`.smf_topics
SET ID_FIRST_MSG = '',
ID_MEMBER_STARTED = '0', ID_LAST_MSG = '',
ID_MEMBER_UPDATED = '0', numReplies = '-1'
WHERE ID_TOPIC = 123456
LIMIT 1;

However, since in mysql, it should be an integer, so an empty string can't be set, so it sets it to the default value of '0'. If you only have one moved topic, it's fine, if you have two, then you have the problem of a UNIQUE key on the table that says that (ID_FIRST_MSG, ID_BOARD) have to be unique.. that's why we get the duplicate entry '0-1' for key 2, 0  for ID_FIRST_MSG, and '1' for ID_BOARD.. and key 2 is the UNIQUE (ID_FIRST_MSG, ID_BOARD) constraint.
Same with ID_LAST_MSG :

  UNIQUE lastMessage (ID_LAST_MSG, ID_BOARD),
  UNIQUE firstMessage (ID_FIRST_MSG, ID_BOARD),

So the solution would be to actually correctly handle the topic_moved_id.
I now fixed it by uncommented the WHERE topic_movied_id = 0 in the conversion script, which mean I lost all my shadow copies, which isn't important, but a better solution would need to be implemented. Or at the very least, uncomment that WHERE by default so people don't get the error and get stuck with a non functioning conversion. It's better to loose shadow copies than to have the script break if shadow copies exist...

I hope this is helpful. If you need more information, let me know.
Thanks,
KaKaRoTo

Advertisement: