]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-7956 - fix problem with messages sent at the same time
authorskodak <skodak>
Sat, 30 Dec 2006 10:55:32 +0000 (10:55 +0000)
committerskodak <skodak>
Sat, 30 Dec 2006 10:55:32 +0000 (10:55 +0000)
message/discussion.php

index 48aa0f7299f1f3d3ea0ea6b091523e5911ea74c0..e32394c731c15710033b938cf982e32ec4c64a92 100644 (file)
             $printmessage = '<div class="message other"><span class="author">'.$fullname.'</span> '.
                 '<span class="time">['.$time.']</span>: '.
                 '<span class="content">'.$printmessage.'</span></div>';
-            $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;
         }
     }
 
             $printmessage = '<div class="message other"><span class="author">'.$mefullname.'</span> '.
                 '<span class="time">['.$time.']</span>: '.
                 '<span class="content">'.$printmessage.'</span></div>';
-            $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;
         }
     }
 
             $printmessage = '<div class="message other"><span class="author">'.$userfullname.'</span> '.
                 '<span class="time">['.$time.']</span>: '.
                 '<span class="content">'.$printmessage.'</span></div>';
-            $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