original_string: public static function legacy_messages_exist($userid) {
          global $DB;
  
          $sql = "SELECT id
                    FROM {message} m
                   WHERE useridfrom = ?
                      OR useridto = ?";
          $messageexists = $DB->record_exists_sql($sql, [$userid, $userid]);
  
          $sql = "SELECT id
                    FROM {message_read} m
                   WHERE useridfrom = ?
                      OR useridto = ?";
          $messagereadexists = $DB->record_exists_sql($sql, [$userid, $userid]);
  
          return $messageexists || $messagereadexists;
      }
code: public static function legacy_messages_exist($userid) {
          global $DB;
  
          $sql = "SELECT id
                    FROM {message} m
                   WHERE useridfrom = ?
                      OR useridto = ?";
          $messageexists = $DB->record_exists_sql($sql, [$userid, $userid]);
  
          $sql = "SELECT id
                    FROM {message_read} m
                   WHERE useridfrom = ?
                      OR useridto = ?";
          $messagereadexists = $DB->record_exists_sql($sql, [$userid, $userid]);
  
          return $messageexists || $messagereadexists;
      }
code_tokens: public static function legacy_messages_exist ( $ userid ) { global $ DB ; $ sql = "SELECT id
                    FROM {message} m
                   WHERE useridfrom = ?
                      OR useridto = ?" ; $ messageexists = $ DB -> record_exists_sql ( $ sql , [ $ userid , $ userid ] ) ; $ sql = "SELECT id
                    FROM {message_read} m
                   WHERE useridfrom = ?
                      OR useridto = ?" ; $ messagereadexists = $ DB -> record_exists_sql ( $ sql , [ $ userid , $ userid ] ) ; return $ messageexists || $ messagereadexists ; }
docstring: Checks if legacy messages exist for a given user.
  
  @param int $userid
  @return bool
docstring_tokens: Checks if legacy messages exist for a given user .