Extends the participants query a bit and only fill "user objects" with uid and name.

This saves a *huge* chunk of queries, especially as we currently don't have a static cache.

The message list is a different beast, that needs to be handled in another issue

CommentFileSizeAuthor
privatemsg.user_load.patch1.63 KBberdir

Comments

naheemsays’s picture

Status: Needs review » Reviewed & tested by the community

Tested and works as expected.

timtrinidad’s picture

Is this going to be committed in an upcoming release?

naheemsays’s picture

it is part of the plan. More testing however can never hurt.

litwol’s picture

Status: Reviewed & tested by the community » Fixed

Immediate perofmrance improvement is minus 2 queries per participant in a thread. However potential imporvement is much greater because we avoid invoking hook_user on load. Also i anticipate bugs like the ones caused by real name module to never happen again :-D. This should force developers use our query builder to extend functionality for users which makes things more controlable on our end... which is good i think.

anyhow. cheers this went in.

naheemsays’s picture

Nice - I especially like that side effect!

litwol’s picture

Status: Fixed » Needs work

in privatemsg_reply()

  $query = _privatemsg_assemble_query('participants', $thread_id);
  $participants = db_query($query['query']);
  while ($result = db_fetch_object($participants)) {
    $recipient = user_load($result->uid);
      $message['recipients'][$recipient->uid] = $recipient;
  }
naheemsays’s picture

We will probably need to keep that user_load as we pass the full $user object through the hook_privatemsg_block_message.

timtrinidad’s picture

Thanks!

berdir’s picture

Status: Needs work » Fixed

@6

That is a api function to send messages, we need the user object there for more than just displaying the name. For example, as nbz mentioned, the pm_block_user module expects the roles array to be there.

Can we think/handle these in other issues so that we can set this one to fixed? One other instance where we can probably replace it is in thread list. My current plan is to use the same approach as in #523064: Display tags in thread list, which means to use one single query to load the recipients of the whole list.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.