UGH, after ages of bughunting i could distill a test case that really makes me nervous:
(users are setup on this site so that new revisions are created by default, if that matters)
hack this into devel/php:

$uid=36; // change as appropriate
$account = user_load($uid);
print "Name before: $account->name\n";

$newname = 'Not '. $account->name;

print "Setting name to: $newname\n";
user_save($account, array('name' => $newname));

$dbresult = db_query('select name from {users} where uid=:uid', array(':uid' => $uid));
foreach($dbresult as $account) {
print "Name in DB: $account->name\n";
}

$account = user_load($uid);
print "Name from user_load: $account->name\n";

givers:

Name before: oldname
Setting name to: Not oldname
Name in DB: Not oldname
Name from user_load: oldname

it seems that cache is not invalidated correctly after save.

moreover:
if you do (note added " 'revision' => 1" in line "user_save"):

$uid=36; // change as appropriate
$account = user_load($uid);
print "Name before: $account->name\n";

$newname = 'Not '. $account->name;

print "Setting name to: $newname\n";
user_save($account, array('name' => $newname, 'revision' => 1));

$dbresult = db_query('select name from {users} where uid=:uid', array(':uid' => $uid));
foreach($dbresult as $account) {
print "Name in DB: $account->name\n";
}

$account = user_load($uid);
print "Name from user_load: $account->name\n";

givers:

Name before: oldname
Setting name to: Not oldname
Name in DB: Not oldname
Name from user_load: Not oldname

(ok, changes correctly saved)

but notices:

Notice: Undefined index: vid in user_revision_user_presave() (Zeile 318 von /home/xl/workspace/sanago/sites/all/modules/user_revision/user_revision.module).
Notice: Undefined index: picture in _user_save_revision() (Zeile 341 von /home/xl/workspace/sanago/sites/all/modules/user_revision/user_revision.module).
CommentFileSizeAuthor
#3 1205018.patch923 bytesjelle_s

Comments

geek-merlin’s picture

i'm not too deep into the user controlle thing, and a quick fix should keep the code as it is,
but a quick glance at the code let me wonder if we should, instead of doing the revisioning in our "userland" module,
use "revisionTable" and "revisionKey" properties of the controller to let them do the work.

see: http://api.drupal.org/api/drupal/includes--entity.inc/class/DrupalDefaul...

(memo to me: write some tests.)

attiks’s picture

axel, i think i tried using revisionTable but at least then couldn't get it working, if i find some time i'll try again

jelle_s’s picture

StatusFileSize
new923 bytes

This patch fixes the notices of the second block of code, still doesn't fix the first part ofcourse.

jelle_s’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
Status: Active » Needs review

Appearantly we did nothing when a user was updated without creating a new revision, so in the php code given as example:
when no new revision is created, we did nothing, the normal user_save still updated the user name in the db, but when we load a user, we get the user name from the latest revision, and this one wasn't updated, so it wasn't really a cache problem. It should be fixed in the latest dev, if anyone could test (besides me ;-)), that would be great

attiks’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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