I noticed some wasted DB access in store.module store_user_history():

  $name = db_result(db_query('SELECT name FROM {users} WHERE uid = %d', $uid));
  $title = t('%username\'s order history', array('%username' => $name));

The required user name can be found in the global $user variable which is already available within the function to get the user id. So the code can be changed to:

  $title = t('%username\'s order history', array('%username' => $user->name));

The second related issue is to how the pages title is set. The module is currently passing the title as a 3rd parameter:

  print theme('page', $output, $title);

This error is made across the majority of e-commerce package modules.
Which as far as I can tell not supported anywhere (at least in v4.6). The corrected code should read:

  drupal_set_title($title);
  print theme('page', $output);

I'd submit a patch but my store.module is still hacked up and there's too many differences from current CVS version.

Comments

matt westgate’s picture

Assigned: Unassigned » matt westgate

That query is there because the admin can browse the user's history and we want to set the user name.

I updated the code to use drupal_set_title($title). Thanks.

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Méléis’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Status: Fixed » Closed (fixed)