original_string: public static function get_conversation_messages(int $userid, int $convid, int $limitfrom = 0, int $limitnum = 0,
          string $sort = 'timecreated ASC', int $timefrom = 0, int $timeto = 0) : array {
  
          if (!empty($timefrom)) {
              // Check the cache to see if we even need to do a DB query.
              $cache = \cache::make('core', 'message_time_last_message_between_users');
              $key = helper::get_last_message_time_created_cache_key($convid);
              $lastcreated = $cache->get($key);
  
              // The last known message time is earlier than the one being requested so we can
              // just return an empty result set rather than having to query the DB.
              if ($lastcreated && $lastcreated < $timefrom) {
                  return [];
              }
          }
  
          $messages = helper::get_conversation_messages($userid, $convid, 0, $limitfrom, $limitnum, $sort, $timefrom, $timeto);
          return helper::format_conversation_messages($userid, $convid, $messages);
      }
code: public static function get_conversation_messages(int $userid, int $convid, int $limitfrom = 0, int $limitnum = 0,
          string $sort = 'timecreated ASC', int $timefrom = 0, int $timeto = 0) : array {
  
          if (!empty($timefrom)) {
              // Check the cache to see if we even need to do a DB query.
              $cache = \cache::make('core', 'message_time_last_message_between_users');
              $key = helper::get_last_message_time_created_cache_key($convid);
              $lastcreated = $cache->get($key);
  
              // The last known message time is earlier than the one being requested so we can
              // just return an empty result set rather than having to query the DB.
              if ($lastcreated && $lastcreated < $timefrom) {
                  return [];
              }
          }
  
          $messages = helper::get_conversation_messages($userid, $convid, 0, $limitfrom, $limitnum, $sort, $timefrom, $timeto);
          return helper::format_conversation_messages($userid, $convid, $messages);
      }
code_tokens: public static function get_conversation_messages ( int $ userid , int $ convid , int $ limitfrom = 0 , int $ limitnum = 0 , string $ sort = 'timecreated ASC' , int $ timefrom = 0 , int $ timeto = 0 ) : array { if ( ! empty ( $ timefrom ) ) { // Check the cache to see if we even need to do a DB query. $ cache = \ cache :: make ( 'core' , 'message_time_last_message_between_users' ) ; $ key = helper :: get_last_message_time_created_cache_key ( $ convid ) ; $ lastcreated = $ cache -> get ( $ key ) ; // The last known message time is earlier than the one being requested so we can // just return an empty result set rather than having to query the DB. if ( $ lastcreated && $ lastcreated < $ timefrom ) { return [ ] ; } } $ messages = helper :: get_conversation_messages ( $ userid , $ convid , 0 , $ limitfrom , $ limitnum , $ sort , $ timefrom , $ timeto ) ; return helper :: format_conversation_messages ( $ userid , $ convid , $ messages ) ; }
docstring: Returns the messages for the defined conversation.
  
  @param  int $userid The current user.
  @param  int $convid The conversation where the messages belong. Could be an object or just the id.
  @param  int $limitfrom Return a subset of records, starting at this point (optional).
  @param  int $limitnum Return a subset comprising this many records in total (optional, required if $limitfrom is set).
  @param  string $sort The column name to order by including optionally direction.
  @param  int $timefrom The time from the message being sent.
  @param  int $timeto The time up until the message being sent.
  @return array of messages
docstring_tokens: Returns the messages for the defined conversation .