Skip to content
Snippets Groups Projects
Commit 7527e789 authored by John VanDyk's avatar John VanDyk
Browse files

Some comments cleanup.

parent 8653fb16
No related branches found
Tags 6.x-1.0
No related merge requests found
......@@ -4,6 +4,8 @@
/**
* @file
* User session handling functions.
*
* An alternative to includes/session.inc.
*/
function sess_open($save_path, $session_name) {
......@@ -38,17 +40,17 @@ function sess_read($key) {
/**
* Write a session to session storage.
*
*
* We have the following cases to handle.
* 1. Anonymous user
* 1a. Without session data.
* 1b. With session data.
* 1c. Session saving has been turned off programatically
* 1c. Session saving has been turned off programatically
* (see session_save_session()).
* 2. Authenticated user.
* 2a. Without session data.
* 2b. With session data.
* 2c. Session saving has been turned off programatically
* 2c. Session saving has been turned off programatically
* (see session_save_session()).
*
* @param $key
......@@ -186,15 +188,16 @@ function sess_user_load($session) {
// We found the client's session record and they are an authenticated user.
if ($session && $session->uid != 0) {
$user = dmemcache_get($session->uid, 'users');
// If the 'users' memcache bin has gone is unavailable, $user will be NULL.
// If the cached user was not found in the 'users' memcache bin, $user will be FALSE.
// If the 'users' memcache bin is unavailable, $user will be NULL.
// If the cached user was not found in the 'users' memcache bin, $user will
// be FALSE.
// In either of these cases, the user must be retrieved from the database.
if (!$user->uid && isset($session->uid) && $session->uid != 0) {
$user = db_fetch_object(db_query('SELECT u.* FROM {users} u WHERE u.uid = %d', $session->uid));
$user = drupal_unpack($user);
// Normally we would join the session and user tables. But we already have the
// session information. So add that in.
// Normally we would join the session and user tables. But we already
// have the session information. So add that in.
$user->sid = $session->sid;
$user->cache = $session->cache;
$user->hostname = $session->hostname;
......@@ -210,25 +213,27 @@ function sess_user_load($session) {
}
}
else if ($user->uid) {
// Got a user object from 'users' memcache bin. Mark it in case modules want
// to know if this use was created from memcache.
// Got a user object from 'users' memcache bin. Mark it in case modules
// want to know that this user was created from memcache.
$user->from_cache = TRUE;
$user->session = empty($session->session) ? '' : $session->session;
}
else {
// We will only get here when the session has a nonzero uid, a user object was
// successfully retrieved from the 'users' bin, and that user's object's uid is 0.
// Not sure why this would ever happen. Leaving former comment in:
// We will only get here when the session has a nonzero uid, a user object
// was successfully retrieved from the 'users' bin, and that user
// object's uid is 0. Not sure why this would ever happen. Leaving former
// comment in:
// This is a rare case that we have a session cached, but no session user object cached.
// This usually only happens if you kill memcached and restart it.
$user = drupal_anonymous_user($session->session);
}
}
// We didn't find the client's record (session has expired), or they are an anonymous user.
// We didn't find the client's record (session has expired), or they are an
// anonymous user.
else {
$session = isset($session->session) ? $session->session : '';
$user = drupal_anonymous_user($session);
}
return $user;
}
......@@ -83,10 +83,8 @@ function memcache_admin_menu() {
);
$sub_count++;
}
}
}
return $items;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment