From 54bb3458317976548afec4412b5399732e3890a8 Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 30 Dec 2006 10:55:32 +0000 Subject: [PATCH] MDL-7956 - fix problem with messages sent at the same time --- message/discussion.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/message/discussion.php b/message/discussion.php index 48aa0f7299f..e32394c731c 100644 --- a/message/discussion.php +++ b/message/discussion.php @@ -212,7 +212,13 @@ $printmessage = '
'.$fullname.' '. '['.$time.']: '. ''.$printmessage.'
'; - $allmessages[$message->timecreated] = $printmessage; + $i=0; + $sortkey = $message->timecreated."$i"; // we need string bacause we would run out of int range + while (array_key_exists($sortkey, $allmessages)) { + $i++; + $sortkey = $message->timecreated."$i"; + } + $allmessages[$sortkey] = $printmessage; } } @@ -226,7 +232,13 @@ $printmessage = '
'.$mefullname.' '. '['.$time.']: '. ''.$printmessage.'
'; - $allmessages[$message->timecreated] = $printmessage; // hack alert - let's hope users will not post exactly at the same time + $i=0; + $sortkey = $message->timecreated."$i"; // we need string bacause we would run out of int range + while (array_key_exists($sortkey, $allmessages)) { + $i++; + $sortkey = $message->timecreated."$i"; + } + $allmessages[$sortkey] = $printmessage; } } @@ -240,7 +252,13 @@ $printmessage = '
'.$userfullname.' '. '['.$time.']: '. ''.$printmessage.'
'; - $allmessages[$message->timecreated] = $printmessage; + $i=0; + $sortkey = $message->timecreated."$i"; // we need string bacause we would run out of int range + while (array_key_exists($sortkey, $allmessages)) { + $i++; + $sortkey = $message->timecreated."$i"; + } + $allmessages[$sortkey] = $printmessage; /// Move the entry to the other table