From: skodak Date: Sat, 30 Dec 2006 10:55:32 +0000 (+0000) Subject: MDL-7956 - fix problem with messages sent at the same time X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=54bb3458317976548afec4412b5399732e3890a8;p=moodle.git MDL-7956 - fix problem with messages sent at the same time --- diff --git a/message/discussion.php b/message/discussion.php index 48aa0f7299..e32394c731 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