diff --git a/mongodb_cache/mongodb_cache.inc b/mongodb_cache/mongodb_cache.inc index d2e3442..edf30b4 100644 --- a/mongodb_cache/mongodb_cache.inc +++ b/mongodb_cache/mongodb_cache.inc @@ -99,7 +99,7 @@ class DrupalMongoDBCache implements DrupalCacheInterface { // timer. The cache variable is loaded into the $user object by _drupal_session_read() // in session.inc. If the data is permanent or we're not enforcing a minimum // cache lifetime always return the cached data. - if ($cache->expire != CACHE_PERMANENT && variable_get('cache_lifetime', 0) && $user->cache > $cache->created) { + if ($cache->expire != CACHE_PERMANENT && variable_get('cache_lifetime', 0) && !empty($user->cache) && $user->cache > $cache->created) { // This cache data is too old and thus not valid for us, ignore it. return FALSE; } diff --git a/mongodb_session/mongodb_session.module b/mongodb_session/mongodb_session.module index f05a9f7..dc5fcfc 100644 --- a/mongodb_session/mongodb_session.module +++ b/mongodb_session/mongodb_session.module @@ -29,9 +29,11 @@ function mongodb_session_user_login($edit, $account) { function _mongodb_session_get_roles($account) { $roles = array(); $roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user'; - $result = db_query("SELECT r.rid, r.name, ur.uid FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid IN (:uids)", array(':uids' => array($account->uid))); - foreach ($result as $role) { - $roles[(int) $role->rid] = $role->name; + if (!empty($account->uid)) { + $result = db_query("SELECT r.rid, r.name, ur.uid FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid IN (:uids)", array(':uids' => array($account->uid))); + foreach ($result as $role) { + $roles[(int) $role->rid] = $role->name; + } } return $roles; }