When attempting to autocomplete the username field in Privatemsg, I would get the following error message:

user warning: Table 'drupal.users' doesn't exist query: SELECT users_user_relationships.name AS name FROM cms_user_relationships INNER JOIN users users_user_relationships ON user_relationships.requestee_id = users_user_relationships.uid WHERE (name LIKE 'Jck%') AND (user_relationships.approved = 1) AND (user_relationships.requester_id =4) ORDER BY name ASC LIMIT 0, 10 in /www/modules/privatemsg/privatemsg.module on line 994.

I have attached a patch that fixes it, but I'm unsure about the quality of my work.

Comments

alex.k’s picture

I think this is the same issue as #514012: User Relationships integration with Privatemsg autocomplete error - could you try the -dev release pls? Thanks.

Jckf’s picture

I'm 99.9% sure you are correct about this. I'll get the dev files later today. Sorry for not searching.

Jckf’s picture

I copied that one file from the dev. release, and the errors are gone (like with my patch) =) I guess this case is closed.

Note: I was talking to the author of Privmsg, and he thinks you're not building your queries correctly =p Look at my patch, as I tried to follow his guidelines =)

Jckf’s picture

Status: Needs review » Closed (fixed)
alex.k’s picture

Status: Closed (fixed) » Needs review

Thanks, will check the queries, and check with the author of UR integration.

mattlc’s picture

here is the fix (excuse me for bad formating) in function "user_relationships_api_privatemsg_sql_autocomplete_alter" :

$fragments['primary_table'] = '{user_relationships}';
  $fragments['select'][] = 'users_user_relationships.name AS name';
  $fragments['where'][] = "name LIKE '%s'";
  $fragments['inner_join'][] = 'INNER JOIN {users} users_user_relationships ON {user_relationships}.requestee_id = users_user_relationships.uid';
  $fragments['query_args'][] = $user->uid;
  $fragments['where'][] = '{user_relationships}.approved = 1';
  $fragments['where'][] = '{user_relationships}.requester_id ='. $user->uid;

It simply not use { and } at lines 22, 24 and 25.

alex.k’s picture

Assigned: Unassigned » alex.k
Status: Needs review » Fixed

It looks like the only remaining issue was that the query didn't use a placeholder for the uid, otherwise it looks equivalent to the patch posted by @Jckf except for table aliases. Corrected in http://drupal.org/cvs?commit=251488, hope that's it :)

Status: Fixed » Closed (fixed)

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