unneccessary query - slow load
elvis2 - December 20, 2007 - 10:08
| Project: | Password reset |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | won't fix |
Jump to:
Description
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:
<?php
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;
?>
#1
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 :|
#2
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
<?php
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;
?>
#3
I cannot reproduce the issue. Please test on a fresh checkout.
#4
It might be worth mentioning I am redirecting a user to a different tpl in my template.php file like so:
<?php
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.
#5
Cannot reproduce.