Closed (duplicate)
Project:
Masquerade
Version:
6.x-1.5
Component:
Code
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Jan 2013 at 11:55 UTC
Updated:
7 Nov 2014 at 13:54 UTC
Jump to comment: Most recent
Hi,
I was having an issue with this module and Memecached where the masquerade table wasn't getting updated with the users $session_id if it changed.
The case I found this happening is when there was a switch user link on the users page. When you clicked the link as an administrator you changed user, but on the next page load you were back to being an administrator.
The code below is how I got around it:
/**
* Implements hook_user().
*
* Updates the masqurade table when the static $old_session_id is empty.
* Probably something to do with memcache.
*/
function apm_masquerade_helper_user($op, &$edit, &$account, $category = NULL) {
static $old_session_id;
switch($op) {
case 'after_update':
global $user;
if (!empty($old_session_id) && session_id() != $old_session_id) {
db_query("UPDATE {masquerade} SET sid = '%s' WHERE sid = '%s'", session_id(), $old_session_id);
}
else {
$result = db_fetch_object(db_query("SELECT uid_as FROM {masquerade} WHERE sid = '%s'", $user->sid));
if ($result->uid_as == $account->uid) {
db_query("UPDATE {masquerade} SET sid = '%s' WHERE sid = '%s'", session_id(), $user->sid);
}
}
break;
}
I can't say definitively if this has been caused by memecached, but thought I would post this up in case anyone gets stuck on it.
Cheers
Tom
Comments
Comment #1
deekayen commented#1926074: Remove {masquerade} table and rely on session flag only