diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index 42af8182f..e428bbe0b 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -1251,10 +1251,12 @@ sub update { # Make a safe copy of properties, we'll be deleting from it $properties = { %$properties }; - $self->uncache; $properties->{lastUpdated} ||= time; + # No userId, bad! + delete $properties->{userId}; + # $self->{_user} contains all fields in `users` table my @userFields = (); my @userValues = (); diff --git a/t/User.t b/t/User.t index be9b9882c..4003a01ef 100644 --- a/t/User.t +++ b/t/User.t @@ -20,7 +20,7 @@ use WebGUI::Cache; use WebGUI::User; use WebGUI::ProfileField; -use Test::More tests => 211; # increment this value for each test you create +use Test::More tests => 221; # increment this value for each test you create use Test::Deep; use Data::Dumper; @@ -115,12 +115,18 @@ $newSession->close; my $now = time; $user->update({ + userId => 'INEDU2COMEINSATURDYTHX', username => "jlumbe", firstName => "John", lastName => "Lumbergh", lastUpdated => $now, }); +isnt( + $user->get('userId'), 'INEDU2COMEINSATURDYTHX', + "update() does not allow changing userId", +); + is( $session->db->quickScalar("SELECT username FROM users WHERE userId=?",[$user->getId]), "jlumbe",