The function password_reset_user() is running a query on the /user/uid page load that doesn't seem like it needs to run. On my end it is loading this query anywhere between 20ms to 1400ms. Did you really intend for this to run when a user is visiting their /user/uid page? This only happens when visiting their own page.

When $op = update you have the following which is creating the query:

    case 'update':
      $qid = $edit['password_reset']['question'];
      $answer = trim($edit['password_reset']['answer']);
      unset($edit['password_reset']);
      // MySQL-only query.
      db_query("REPLACE INTO {password_reset_users} (uid, qid, answer) VALUES (%d, %d, '%s')", $account->uid, $qid, $answer);
      break;

Comments

Zen’s picture

Status: Active » Postponed (maintainer needs more info)

Are you saying that "REPLACE INTO {password_reset_users} (uid, qid, answer) VALUES (%d, %d, '%s')" is slow? I don't see why it would be. It should also only be triggered when the user edit form is submitted.

Incidentally, the REPLACE query should be replaced by a DELETE + INSERT :|

elvis2’s picture

I guess slow can be defined by many things. But, it should not be taking place when "viewing" the user/ page, when logged in and visiting your own user page... Maybe another case needs to be added


case 'view':
// do nothing here
break;

    case 'update':
      $qid = $edit['password_reset']['question'];
      $answer = trim($edit['password_reset']['answer']);
      unset($edit['password_reset']);
      // MySQL-only query.
      db_query("REPLACE INTO {password_reset_users} (uid, qid, answer) VALUES (%d, %d, '%s')", $account->uid, $qid, $answer);
      break;

Zen’s picture

I cannot reproduce the issue. Please test on a fresh checkout.

elvis2’s picture

It might be worth mentioning I am redirecting a user to a different tpl in my template.php file like so:

function phptemplate_user_profile($user, $fields = array()) {
drupal_add_js('misc/collapse.js');

	if ($GLOBALS['user']->uid == $user->uid):
		return _phptemplate_callback('my_profile', array('user' => $user, 'fields' => $fields));
	else:
		return _phptemplate_callback('others_profile', array('user' => $user, 'fields' => $fields));
	endif;
  }

I am not sure if that would change anything, but I thought I would mention it.

Zen’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Cannot reproduce.