Fixed Edit History importer (vB) importing edits in wrong version order

AlexT

Well-known member
After importing the edit history from vB (3.8 tested), the edits in the history are not in the correct order.

Here is why:

vB stores edits in its history table slightly differently than xF. Specifically, in vB, in the postedithistory table, in each row, pagetext refers to the current edit. In contrast, in xF, in the xf_edit_history table, in each row, old_text refers to the previous edit.

Also, if you look at an imported edit history, you see that the first edit (in the bottom of the list), is always identical to the actual first post (in vBulletin in the postedithistory table it is referred to the "original" post).

I have posted a code snippet that would import the edit history in the correct order and make sure that the edit labelled as "original" would not be imported as an edit.
 
Something else:

- Using the importer from 1.2b5, a post's edit_count isn't correctly set. The importer sets it either to 0 for no edits, or to 1 for one or more edits, rather than filling it with actual number of edits. This appears to be intentional (shortcut?).

- Edits from the history aren't actually imported. This is a bug caused by this line (~2774):

PHP:
'old_text' => $this->_convertToUtf8($this->$edit['pagetext'])

should be

PHP:
'old_text' => $this->_convertToUtf8($edit['pagetext'])
 
The edit count thing is intentional (especially as the full data may have been pruned, so the edit history total may not be correct either).
 
I see. Mike, did you look at the code snippet I linked above? Rather than going through vB's postedithistory table by postedithistoryid, I processed the table by postid. This way, I know exactly how many edits are available per post (so a post's edit_count can be set correctly), and you can also shuffle around the pagetext to fix the versioning order.
 
Kier, sorry to bring this one up again; I see in 1.2 RC you're importing the edit history sorted by postid now. Skimming the code, though, I don't see that the edit order within each particular post history hasn't been fixed.

vB stores edits in its history table slightly differently than xF. Specifically, in vB, in the postedithistory table, in each row, pagetext refers to the current edit. In contrast, in xF, in the xf_edit_history table, in each row, old_text refers to the previous edit.

I haven't done a test import with RC, and perhaps I am wrong. :oops:
 
The page text is offset by 1 edit ($pageText refers to the previous edit) so it should be ok.
 
Top Bottom