Log => Notice: Trying to get property of non-object in sess_user_load() -> memcache-session.inc

Fix: (edit memcache-session.inc)

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 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) {
+    if (empty($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));
      if (!$user->status) {
        $user = drupal_anonymous_user($session->session);
      }
      else {
CommentFileSizeAuthor
#1 memcache-1177462-1.patch2.99 KBmikeytown2

Comments

mikeytown2’s picture

Status: Active » Needs review
StatusFileSize
new2.99 KB

patch also contains white space fixes.

jeffsheltren’s picture

Status: Needs review » Reviewed & tested by the community

I'm unable to reproduce the notice under php 5.3 with errors/notices enabled, so I'm not sure what that's about, but your patch works for me and seems valid.

jeremy’s picture

Status: Reviewed & tested by the community » Fixed

Automatically closed -- issue fixed for 2 weeks with no activity.