Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-30370 Meta: Oracle SQL issues
  3. MDL-24678

little bug in the chat_get_latest_message function, in chat lib

    Details

    • Type: Sub-task
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.9.7
    • Fix Version/s: None
    • Component/s: Chat
    • Labels:
      None
    • Environment:
      Linux, with postgres, moodle 1.9.7

      Description

      This bug affects all moodle version, i think.

      The bug is in the chat lib (mod/chat/lib.php), in the function chat_get_latest_message($chatid, $groupid=0)

      If the chat message have the same timestamp, it could get wrong last chat message,
      this is cause by this lines (line 440)

      if (!$rs = $db->SelectLimit("SELECT *
      FROM {$CFG->prefix}chat_messages
      WHERE chatid = '$chatid' $groupselect
      ORDER BY timestamp DESC", 1))

      { return false; }

      it's could be fix by change to this code:

      if (!$rs = $db->SelectLimit("SELECT *
      FROM {$CFG->prefix}chat_messages
      WHERE chatid = '$chatid' $groupselect
      ORDER BY timestamp DESC, id DESC", 1))

      { return false; }

      or with this query that not use any limit or sort

      SELECT * FROM mdl_chat_messages WHERE chatid = <CHAT_ID> and timestamp=(SELECT MAX(timestamp) FROM mdl_chat_messages WHERE chatid = <CHAT_ID>) and id=(SELECT MAX(id) from mdl_chat_messages WHERE chatid = <CHAT_ID>);

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: