MyBB Community Forums

Full Version: PUNBB 1.2.x Merge Error - Out of range value for column 'firstpost'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
On the threads portion of the merge from PunBB 1.2.22 I get this error

MyBB Merge System - Version: 1.4 Final
Threads
156 threads are importing right now. There are 0 threads left to import and 0 pages left.
MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.
SQL Error:
    1264 - Out of range value for column 'firstpost' at row 1
Query:
    INSERT INTO mybb_threads (`import_tid`,`sticky`,`fid`,`firstpost`,`dateline`,`subject`,`poll`,`uid`,`import_uid`,`views`,`closed`,`totalratings`,`notes`,`visible`,`unapprovedposts`,`numratings`,`attachmentcount`,`username`,`lastpost`,`lastposter`,`lastposteruid`,`replies`,`icon`,`deletetime`) VALUES ('2','0','7','-6','1142113292','Best Metal Gear Solid game?','0','3','3','520','0','0','','1','0','0','0','','0','','0','0','0','0') 

This is a brand new install of MyBB that I installed and then after setting that up, I'm doing the merge. I cant quite figure this one out, because I cant figure out how its getting that -6 in there, the punbb database doesnt have a firstpost in the punbb_topics table


I'm looking over the code and have figured the query to be

SELECT *
FROM `punbb_posts`
WHERE topic_id=2
ORDER BY posted ASC
LIMIT 1 

In convert\boards\punbb\threads.php the following code calculates the firstpost field
$insert_data['firstpost'] = ((-1) * $this->get_first_post($data['id']));

Thing is I dont know why they want it to be negative, does mybb use negative numbers for the firstpost?



I just looked at the mybb_threads table and firstpost is setup as
int(10)  	 	UNSIGNED  	No(null)  	0(default)

so why is it multiplying by -1?
That is curious, I know it should be negative... Very strange. In the PunBB Merge system do posts come before or after threads? I'm going to guess before. If before then the $this->get_first_post($data['id']) should return the post ID of the CONVERTED post (the first post in the thread as it is on the MyBB board, which may be different from the number it has on your pun board...); which would mean that line should read:
$insert_data['firstpost'] = $this->get_first_post($data['id']);
Which you can try and see if it works or not. Hopefully it does. If not I'll look at the actual code and let you know. The only reason I can think of to multiple it by -1 is if that function actually returns a negative value.
I made it so its not mulitiplied by a negative and it got past that issue.

I ran into a few other snags, while doing my conversion, it took about 10 reinstalls of mybb and attempts with the merge tool along with me making some modifications in my punbb db and in the merge code.

Some other problems I ran into, was that some users had a NULL for lastpost, the Guest also had to have some fields changed as well from NULL and put in some other data for it. I also went ahead and modified the code so that it pulls in the Guest posts, because I had guest posting turned on in my punbb forum and the merge wouldnt complete unless I made it do so.

I pulled my hair out a bit, but its converted now. Toungue
Instead of reinstalling MyBB you should have just backed up your MyBB db right after a fresh install, and right before merging Smile

Then you can revert as many times as you want.