While updating from 6.x-1.x to 6.x-2.x, the dates of the chat messages are mixed up. The line that does the ccid update updates the same chat node twice, because of the way the code is written:

db_query("UPDATE {chatroom_msg} SET ccid = %d WHERE ccid = %d", $new_chat_node->nid, $old_chat_id);

Here if the $new_chat_node->nid happens to correspond to another $old_chat_id, the chat node is updated twice, and ends up getting the wrong ccid. This, for example causes chats from 2009 chatrooms to show up in 2011 chatrooms.

This patch fixes this issue. It also fixes the issue of the created and changed date not being migrated over properly.
The patch is built against the latest CVS version as of Feb 23rd 2011

CommentFileSizeAuthor
update.patch2.45 KBanand_s
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

anand_s’s picture

Version: 6.x-2.13 » master
Anonymous’s picture

thanks, i'll review this shortly.

do you have a sample db dump i could use to test this?

anand_s’s picture

To test it, all you have to do is to create a row in {chatroom_msg} with ccid = n, where n > max(nid in {node}), but <= [max(nid in nodes) + no. of chats in {chatroom_chat} (that will be converted to nodes during update)].

Assume there already exists, in {chatroom_msg} a row with ccid = n(ccid). At some point during the update you would have set, in {chatroom_msg} some ccid from old_ccid to new_ccid = n(nid). n(nid) here is the nid in {node} for the chatroom that contains that chat message. But this n(nid) happens to be equal to an already existing ccid = n(ccid). So now there are two rows with ccid = n(ccid) = n(nid). Next you update another ccid from old_ccid = n(ccid) to n'. But here, two rows are updated -- the one with the updated ccid = n(nid), and one with already existing ccid = n(ccid). Behold, you've got a chat with the wrong ccid, which shows up in the wrong chatroom.

Hope this explanation helps.

I'll try to send you a sample db when I get some time.