user object not getting updated on user_save with memcache-session.inc

Jeremy - December 19, 2008 - 00:03
Project:Memcache API and Integration
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

If you enable memcache-session.inc, then visit the administration pages and click "Show descriptions" or "Hide descriptions", nothing happens. If you log out and log back in, then the change takes effect. This affects both the 6.x and 5.x versions.

#1

andreiashu - January 5, 2009 - 05:08

Yup, i can replicate this bug
Edit: I tested on the 6.x version.

#2

Jeremy - August 18, 2009 - 15:42
Title:Unable to show/hide descriptions on admin page with memcache-session.inc» user object not getting updated on user_save with memcache-session.inc
Version:5.x-1.x-dev» 6.x-1.x-dev

This bug also strikes if you try and edit your own user account. For example, edit your username and note that your user block's title doesn't change, still showing the old username.

When a user account is edited, or the show/hide descriptions link is clicked, the changes to the user are updated with a call to user_save(). However, user_save() does not update the global $user object, as it can be used to update the current user or a different user. In sess_write(), we update the 'users' cache table with the global $user object, and thus these changes are not saved in memory. You only see these changes if you log out and log back in, causing the 'users' cache entry for your user account to be rebuilt.

The attached patch modifies the user.module, which is obviously not the right way to do this. A better solution would be to create a module, perhaps memcache-session.module, and implementing hook_user(), flushing the appropriate users cache when 'after_update' is invoked. However, I'm hoping to get more eyes on this first. Thoughts?

#3

Jeremy - August 18, 2009 - 15:43

Attaching the patch...

AttachmentSize
memcache.patch 1.16 KB
 
 

Drupal is a registered trademark of Dries Buytaert.