kareila: (Default)
kareila ([personal profile] kareila) wrote in [site community profile] changelog2010-07-26 10:48 pm

[dw-free] migrate LJ::update_user to $u->update_self

[commit: http://hg.dwscoalition.org/dw-free/rev/9ec64bf149c0]

http://bugs.dwscoalition.org/show_bug.cgi?id=2760

Use a user method whenever possible to update information about the user.

Patch by [personal profile] kareila.

Files modified:
  • bin/moveucluster.pl
  • cgi-bin/DW/Setting/ContactInfo.pm
  • cgi-bin/DW/Setting/TxtMsgSetup.pm
  • cgi-bin/LJ/Console/Command/ChangeCommunityAdmin.pm
  • cgi-bin/LJ/Console/Command/ResetPassword.pm
  • cgi-bin/LJ/Console/Command/SynMerge.pm
  • cgi-bin/LJ/Console/Command/Unsuspend.pm
  • cgi-bin/LJ/Setting/Birthday.pm
  • cgi-bin/LJ/Setting/BoolSetting.pm
  • cgi-bin/LJ/Setting/CommentEmailNotify.pm
  • cgi-bin/LJ/Setting/EmailFormat.pm
  • cgi-bin/LJ/Setting/EnableComments.pm
  • cgi-bin/LJ/Setting/Name.pm
  • cgi-bin/LJ/SynSuck.pm
  • cgi-bin/LJ/Test.pm
  • cgi-bin/LJ/User.pm
  • cgi-bin/LJ/Userpic.pm
  • cgi-bin/LJ/Widget/CreateAccountProfile.pm
  • cgi-bin/LJ/Widget/MoodThemeChooser.pm
  • htdocs/changeemail.bml
  • htdocs/changepassword.bml
  • htdocs/community/settings.bml
  • htdocs/community/transfer.bml
  • htdocs/editicons.bml
  • htdocs/manage/moodthemes.bml
  • htdocs/manage/profile/index.bml
  • htdocs/register.bml
  • t/console-changecommunityadmin.t
  • t/console-changejournaltype.t
  • t/console-finduser.t
  • t/esn-journalnewentry.t
  • t/user-infoshow-migrate.t
  • t/userloading.t
--------------------------------------------------------------------------------
diff -r 3cb76b9d702a -r 9ec64bf149c0 bin/moveucluster.pl
--- a/bin/moveucluster.pl	Mon Jul 26 17:18:48 2010 -0500
+++ b/bin/moveucluster.pl	Mon Jul 26 17:47:46 2010 -0500
@@ -508,9 +508,9 @@ sub moveUser {
                  "VALUES (?,?,?,UNIX_TIMESTAMP(),UNIX_TIMESTAMP())", undef, 
                  $userid, $sclust, 0);
 
-        LJ::update_user($userid, { clusterid => 0,
-                                   statusvis => 'X',
-                                   raw => "caps=caps&~(1<<$readonly_bit), statusvisdate=NOW()" })
+        $u->update_self( { clusterid => 0,
+                           statusvis => 'X',
+                           raw => "caps=caps&~(1<<$readonly_bit), statusvisdate=NOW()" } )
             or die "Couldn't update user to expunged";
 
         # note that we've expunged this user in the "expunged_users" db table
@@ -606,8 +606,8 @@ sub moveUser {
     my $cmid = $dbh->{'mysql_insertid'};
 
     # set readonly cap bit on user
-    unless ($opts->{prelocked} ||
-            LJ::update_user($userid, { raw => "caps=caps|(1<<$readonly_bit)" }))
+    unless ( $opts->{prelocked} ||
+             $u->update_self( { raw => "caps=caps|(1<<$readonly_bit)" } ) )
     {
         die "Failed to set readonly bit on user: $user\n";
     }
@@ -983,12 +983,12 @@ sub moveUser {
     my $unlocked;
     if (! $verify_code || $verify_code->()) {
         # unset readonly and move to new cluster in one update
-        $unlocked = LJ::update_user($userid, { clusterid => $dclust, raw => "caps=caps&~(1<<$readonly_bit)" });
+        $unlocked = $u->update_self( { clusterid => $dclust, raw => "caps=caps&~(1<<$readonly_bit)" } );
         print "Moved.\n" if $optv;
     } else {
         # job server went away or we don't have permission to flip the clusterid attribute
         # so just unlock them
-        $unlocked = LJ::update_user($userid, { raw => "caps=caps&~(1<<$readonly_bit)" });
+        $unlocked = $u->update_self( { raw => "caps=caps&~(1<<$readonly_bit)" } );
         die "Job server said no.\n";
     }
 
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/DW/Setting/ContactInfo.pm
--- a/cgi-bin/DW/Setting/ContactInfo.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/DW/Setting/ContactInfo.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -80,7 +80,7 @@ sub save {
     $class->error_check( $u, $args );
 
     my $val = $class->get_arg( $args, "contactinfo" );
-    LJ::update_user( $u, { allow_contactshow => $val } );
+    $u->update_self( { allow_contactshow => $val } );
 
     return 1;
 }
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/DW/Setting/TxtMsgSetup.pm
--- a/cgi-bin/DW/Setting/TxtMsgSetup.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/DW/Setting/TxtMsgSetup.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -154,7 +154,7 @@ sub save {
     my $txtmsg_status = $cleared || ( $security && $security eq 'none' )
                         ? "off" : "on";
 
-    LJ::update_user( $u, { 'txtmsg_status' => $txtmsg_status } );
+    $u->update_self( { txtmsg_status => $txtmsg_status } );
 
     my $dbh = LJ::get_db_writer();
 
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Console/Command/ChangeCommunityAdmin.pm
--- a/cgi-bin/LJ/Console/Command/ChangeCommunityAdmin.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Console/Command/ChangeCommunityAdmin.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -62,7 +62,7 @@ sub execute {
     $dbh->do("DELETE FROM infohistory WHERE userid = ?", undef, $ucomm->id);
 
     # change password to blank and set email of community to new maintainer's email
-    LJ::update_user($ucomm, { password => '', email => $unew->email_raw });
+    $ucomm->update_self( { password => '', email => $unew->email_raw } );
     $ucomm->update_email_alias;
 
     # log to statushistory
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Console/Command/ResetPassword.pm
--- a/cgi-bin/LJ/Console/Command/ResetPassword.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Console/Command/ResetPassword.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -49,7 +49,7 @@ sub execute {
     return $self->error("Failed to insert old password into infohistory.")
         unless $rval;
 
-    LJ::update_user($u, { password => $newpass, })
+    $u->update_self( { password => $newpass, } )
         or return $self->error("Failed to set new password for $username");
 
     $u->kill_all_sessions;
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Console/Command/SynMerge.pm
--- a/cgi-bin/LJ/Console/Command/SynMerge.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Console/Command/SynMerge.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -74,7 +74,7 @@ sub execute {
     my $to_oldurl = $dbh->selectrow_array("SELECT synurl FROM syndicated WHERE userid=?", undef, $to_u->id);
 
     # 1) set up redirection for 'from_user' -> 'to_user'
-    LJ::update_user($from_u, { 'journaltype' => 'R', 'statusvis' => 'R' });
+    $from_u->update_self( { journaltype => 'R', statusvis => 'R' } );
     $from_u->set_prop("renamedto", $to_user)
         or return $self->error("Unable to set userprop.  Database unavailable?");
 
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Console/Command/Unsuspend.pm
--- a/cgi-bin/LJ/Console/Command/Unsuspend.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Console/Command/Unsuspend.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -104,7 +104,7 @@ sub execute {
             next;
         }
 
-        LJ::update_user($u->{'userid'}, { statusvis => 'V', raw => 'statusvisdate=NOW()' });
+        $u->update_self( { statusvis => 'V', raw => 'statusvisdate=NOW()' } );
         $u->{statusvis} = 'V';
 
         LJ::statushistory_add($u, $remote, "unsuspend", $reason);
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Setting/Birthday.pm
--- a/cgi-bin/LJ/Setting/Birthday.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Setting/Birthday.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -90,7 +90,7 @@ sub save {
     my %update = (
         'bdate' => sprintf("%04d-%02d-%02d", $year, $month, $day),
     );
-    LJ::update_user($u, \%update);
+    $u->update_self( \%update );
 
     # for the directory
     my $sidx_bday = sprintf("%02d-%02d", $month, $day);
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Setting/BoolSetting.pm
--- a/cgi-bin/LJ/Setting/BoolSetting.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Setting/BoolSetting.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -71,7 +71,7 @@ sub save {
     if (my $prop = $class->prop_name) {
         return $u->set_prop($prop, $new_val);
     } elsif (my $field = $class->user_field) {
-        return LJ::update_user($u, { $field => $new_val });
+        return $u->update_self( { $field => $new_val } );
     }
     croak "No prop_name or user_field set";
 }
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Setting/CommentEmailNotify.pm
--- a/cgi-bin/LJ/Setting/CommentEmailNotify.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Setting/CommentEmailNotify.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -75,7 +75,7 @@ sub save {
     my ($class, $u, $args) = @_;
 
     my $val = $class->get_arg($args, "commentemailnotify") ? "Y" : "N";
-    LJ::update_user($u, { opt_gettalkemail => $val });
+    $u->update_self( { opt_gettalkemail => $val } );
 
     return 1;
 }
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Setting/EmailFormat.pm
--- a/cgi-bin/LJ/Setting/EmailFormat.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Setting/EmailFormat.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -77,7 +77,7 @@ sub save {
     $class->error_check($u, $args);
 
     my $val = $class->get_arg($args, "emailformat");
-    LJ::update_user($u, { opt_htmlemail => $val });
+    $u->update_self( { opt_htmlemail => $val } );
 
     return 1;
 }
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Setting/EnableComments.pm
--- a/cgi-bin/LJ/Setting/EnableComments.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Setting/EnableComments.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -72,7 +72,7 @@ sub save {
     my $showtalklinks = $val eq "none" ? "N" : "Y";
     my $whocanreply = $val eq "none" ? $u->{opt_whocanreply} : $val;
 
-    LJ::update_user($u, { opt_showtalklinks => $showtalklinks, opt_whocanreply => $whocanreply });
+    $u->update_self( { opt_showtalklinks => $showtalklinks, opt_whocanreply => $whocanreply } );
 
     return 1;
 }
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Setting/Name.pm
--- a/cgi-bin/LJ/Setting/Name.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Setting/Name.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -52,8 +52,8 @@ sub save_text {
     my ($class, $u, $txt) = @_;
     $txt = LJ::trim($txt);
     $txt = LJ::text_trim($txt, LJ::BMAX_NAME, LJ::CMAX_NAME);
-    return 0 unless LJ::update_user($u, { name => $txt });
-    LJ::load_userid($u->{userid}, "force");
+    return 0 unless $u && $u->update_self( { name => $txt } );
+    LJ::load_userid( $u->userid, "force" );
     return 1;
 }
 
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/SynSuck.pm
--- a/cgi-bin/LJ/SynSuck.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/SynSuck.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -439,7 +439,7 @@ sub process_content {
         $title = $su->{'user'} unless LJ::is_utf8($title);
         if (defined $title && $title ne $su->{'name'}) {
             $title =~ s/[\n\r]//g;
-            LJ::update_user($su, { name => $title });
+            $su->update_self( { name => $title } );
             $su->set_prop( "urlname", $title );
         }
 
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Test.pm
--- a/cgi-bin/LJ/Test.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Test.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -103,7 +103,7 @@ sub temp_comm {
     my $u = temp_user();
 
     # update journaltype
-    LJ::update_user($u, { journaltype => 'C' });
+    $u->update_self( { journaltype => 'C' } );
 
     # communities always have a row in 'community'
     my $dbh = LJ::get_db_writer();
@@ -120,7 +120,7 @@ sub temp_feed {
     my $u = temp_user();
 
     # update journaltype
-    LJ::update_user($u, { journaltype => 'Y' });
+    $u->update_self( { journaltype => 'Y' } );
 
     # communities always have a row in 'syndicated'
     my $dbh = LJ::get_db_writer();
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/User.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -145,7 +145,7 @@ sub create {
     $dbh->do("INSERT INTO userusage (userid, timecreate) VALUES (?, NOW())",
              undef, $userid);
 
-    my $u = LJ::load_userid($userid, "force");
+    my $u = LJ::load_userid( $userid, "force" ) or return;
 
     my $status   = $opts{status}   || ($LJ::EVERYONE_VALID ? 'A' : 'N');
     my $name     = $opts{name}     || $username;
@@ -153,8 +153,8 @@ sub create {
     my $email    = $opts{email}    || "";
     my $password = $opts{password} || "";
 
-    LJ::update_user($u, { 'status' => $status, 'name' => $name, 'bdate' => $bdate,
-                          'email' => $email, 'password' => $password, %LJ::USER_INIT });
+    $u->update_self( { status => $status, name => $name, bdate => $bdate,
+                       email => $email, password => $password, %LJ::USER_INIT } );
 
     my $remote = LJ::get_remote();
     $u->log_event('account_create', { remote => $remote });
@@ -520,8 +520,8 @@ sub set_statusvis {
         });
 
     # do update
-    return LJ::update_user($u, { statusvis => $statusvis,
-                                 raw => 'statusvisdate=NOW()' });
+    return $u->update_self( { statusvis => $statusvis,
+                              raw => 'statusvisdate=NOW()' } );
 }
 
 
@@ -1761,6 +1761,12 @@ sub uncache_prop {
 }
 
 
+sub update_self {
+    my ( $u, $ref ) = @_;
+    return LJ::update_user( $u, $ref );
+}
+
+
 # returns self (the $u object which can be used for $u->do) if
 # user is writable, else 0
 sub writer {
@@ -2523,7 +2529,7 @@ sub modify_caps {
     }
 
     # get a u object directly from the db
-    my $u = LJ::load_userid( $userid, "force" );
+    my $u = LJ::load_userid( $userid, "force" ) or return;
 
     # add new caps
     my $newcaps = int( $u->{caps} );
@@ -2560,7 +2566,7 @@ sub modify_caps {
     }
 
     # update user row
-    return 0 unless LJ::update_user( $u, { caps => $newcaps } );
+    return 0 unless $u->update_self( { caps => $newcaps } );
 
     $u->{caps} = $newcaps;
     $argu->{caps} = $newcaps;
@@ -3030,7 +3036,7 @@ sub _lazy_migrate_infoshow {
     }
 
     # setting allow_infoshow to ' ' means we've migrated it
-    LJ::update_user($u, { allow_infoshow => ' ' })
+    $u->update_self( { allow_infoshow => ' ' } )
         or die "unable to update user after infoshow migration";
     $u->{allow_infoshow} = ' ';
 
@@ -3258,7 +3264,7 @@ sub set_bio {
     my $newbio = $bio_absent eq "yes" ? $oldbio : $text;
     my $has_bio = ( $newbio =~ /\S/ ) ? "Y" : "N";
 
-    LJ::update_user( $u, { has_bio => $has_bio } );
+    $u->update_self( { has_bio => $has_bio } );
 
     # update their bio text
     return if ( $oldbio eq $text ) || ( $bio_absent eq "yes" );
@@ -4368,7 +4374,7 @@ sub reset_email {
 
     $update_opts ||= { status => 'T' };
     $update_opts->{email} = $newemail;
-    LJ::update_user( $u, $update_opts ) or
+    $u->update_self( $update_opts ) or
         return $errsub->( LJ::Lang::ml( "email.emailreset.error",
                                         { user => $u->user } ) );
 
@@ -7120,18 +7126,12 @@ sub memcache_set_u
 }
 
 
+# FIXME: this should go away someday... see bug 2760
 sub update_user
 {
-    my ($arg, $ref) = @_;
-    my @uid;
-
-    if (ref $arg eq "ARRAY") {
-        @uid = @$arg;
-    } else {
-        @uid = want_userid($arg);
-    }
-    @uid = grep { $_ } map { $_ + 0 } @uid;
-    return 0 unless @uid;
+    my ( $u, $ref ) = @_;
+    my $uid = LJ::want_userid( $u ) + 0;
+    return 0 unless $uid;
 
     my @sets;
     my @bindparams;
@@ -7141,9 +7141,9 @@ sub update_user
             $used_raw = 1;
             push @sets, $v;
         } elsif ($k eq 'email') {
-            set_email($_, $v) foreach @uid;
+            LJ::set_email( $uid, $v );
         } elsif ($k eq 'password') {
-            set_password($_, $v) foreach @uid;
+            LJ::set_password( $uid, $v );
         } else {
             push @sets, "$k=?";
             push @bindparams, $v;
@@ -7154,31 +7154,28 @@ sub update_user
     return 0 unless $dbh;
     {
         local $" = ",";
-        my $where = @uid == 1 ? "userid=$uid[0]" : "userid IN (@uid)";
+        my $where = "userid=$uid";
         $dbh->do("UPDATE user SET @sets WHERE $where", undef,
                  @bindparams);
         return 0 if $dbh->err;
     }
     if (@LJ::MEMCACHE_SERVERS) {
-        LJ::memcache_kill($_, "userid") foreach @uid;
+        LJ::memcache_kill( $uid, "userid" );
     }
 
     if ($used_raw) {
         # for a load of userids from the master after update
         # so we pick up the values set via the 'raw' option
-        require_master(sub { LJ::load_userids(@uid) });
-    } else {
-        foreach my $uid (@uid) {
-            while (my ($k, $v) = each %$ref) {
-                my $cache = $LJ::REQ_CACHE_USER_ID{$uid} or next;
-                $cache->{$k} = $v;
-            }
-        }
-    }
-
-    # log this updates
-    LJ::Hooks::run_hooks("update_user", userid => $_, fields => $ref)
-        for @uid;
+        require_master( sub { LJ::load_userid($uid) } );
+    } else {
+        while ( my ($k, $v) = each %$ref ) {
+            my $cache = $LJ::REQ_CACHE_USER_ID{$uid} or next;
+            $cache->{$k} = $v;
+        }
+    }
+
+    # log this update
+    LJ::Hooks::run_hooks( "update_user", userid => $uid, fields => $ref );
 
     return 1;
 }
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Userpic.pm
--- a/cgi-bin/LJ/Userpic.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Userpic.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -738,7 +738,7 @@ sub make_default {
     my $u = $self->owner
         or die;
 
-    LJ::update_user($u, { defaultpicid => $self->id });
+    $u->update_self( { defaultpicid => $self->id } );
     $u->{'defaultpicid'} = $self->id;
 }
 
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Widget/CreateAccountProfile.pm
--- a/cgi-bin/LJ/Widget/CreateAccountProfile.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Widget/CreateAccountProfile.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -229,7 +229,7 @@ sub handle_post {
     LJ::EmbedModule->parse_module_embed($u, \$post->{bio});
 
     unless (keys %{$from_post{errors}}) {
-        LJ::update_user($u, { name => $post->{name} });
+        $u->update_self( { name => $post->{name} } );
         $u->invalidate_directory_record;
         $u->set_prop('gender', $post->{gender});
         $u->set_interests($old_interests, \@valid_ints);
diff -r 3cb76b9d702a -r 9ec64bf149c0 cgi-bin/LJ/Widget/MoodThemeChooser.pm
--- a/cgi-bin/LJ/Widget/MoodThemeChooser.pm	Mon Jul 26 17:18:48 2010 -0500
+++ b/cgi-bin/LJ/Widget/MoodThemeChooser.pm	Mon Jul 26 17:47:46 2010 -0500
@@ -132,7 +132,7 @@ sub handle_post {
     foreach (keys %update) {
         delete $update{$_} if $u->{$_} eq $update{$_};
     }
-    LJ::update_user($u, \%update) if %update;
+    $u->update_self( \%update ) if %update;
 
     # reload the user object to force the display of these changes
     $u = LJ::load_user($u->user, 'force');
diff -r 3cb76b9d702a -r 9ec64bf149c0 htdocs/changeemail.bml
--- a/htdocs/changeemail.bml	Mon Jul 26 17:18:48 2010 -0500
+++ b/htdocs/changeemail.bml	Mon Jul 26 17:47:46 2010 -0500
@@ -155,7 +155,7 @@ body<=
         };
         $tochange->{status} = 'T' if $u->{status} eq 'A';
 
-        LJ::update_user($u, $tochange);
+        $u->update_self( $tochange );
 
         # send letter to old email address
         my @date = localtime(time);
diff -r 3cb76b9d702a -r 9ec64bf149c0 htdocs/changepassword.bml
--- a/htdocs/changepassword.bml	Mon Jul 26 17:18:48 2010 -0500
+++ b/htdocs/changepassword.bml	Mon Jul 26 17:47:46 2010 -0500
@@ -177,7 +177,7 @@ body<=
 
      $u->log_event('password_change', { remote => $remote });
 
-     LJ::update_user($u, { password => $POST{'newpass1'} });
+     $u->update_self( { password => $POST{newpass1} } );
 
      # if we used an authcode, we'll need to expire it now
      LJ::mark_authaction_used($aa) if $authu;
diff -r 3cb76b9d702a -r 9ec64bf149c0 htdocs/community/settings.bml
--- a/htdocs/community/settings.bml	Mon Jul 26 17:18:48 2010 -0500
+++ b/htdocs/community/settings.bml	Mon Jul 26 17:47:46 2010 -0500
@@ -130,7 +130,7 @@ body<=
                 $nonmember_posting = 1;
             }
 
-            LJ::update_user($cu, { journaltype => 'C', password => '' });
+            $cu->update_self( { journaltype => 'C', password => '' } );
             if ($mode eq 'create') {
                 LJ::set_rel($cu, $remote, 'A');
 
diff -r 3cb76b9d702a -r 9ec64bf149c0 htdocs/community/transfer.bml
--- a/htdocs/community/transfer.bml	Mon Jul 26 17:18:48 2010 -0500
+++ b/htdocs/community/transfer.bml	Mon Jul 26 17:47:46 2010 -0500
@@ -54,7 +54,7 @@ _c?>
         unless (%errors) {
             $cu->log_event('maintainer_add', { actiontarget => $remote->{userid}, remote => $remote });
             LJ::set_rel($cu, $remote, 'A');
-            LJ::update_user($cu, { password => '' });
+            $cu->update_self( { password => '' } );
             $body = "<?h1 $ML{'.success.title'} h1?><?p ";
             $body .= BML::ml('.success.body', { comm =>  LJ::ljuser($cu, { type => 'C' }) });
             $body .= " p?>";
diff -r 3cb76b9d702a -r 9ec64bf149c0 htdocs/editicons.bml
--- a/htdocs/editicons.bml	Mon Jul 26 17:18:48 2010 -0500
+++ b/htdocs/editicons.bml	Mon Jul 26 17:47:46 2010 -0500
@@ -723,7 +723,7 @@ sub update_userpics
         }
     } elsif ($new_default eq '0' && $u->{'defaultpicid'}) {
         # selected the "no default picture" option
-        LJ::update_user($u, { defaultpicid => 0 });
+        $u->update_self( { defaultpicid => 0 } );
         $u->{'defaultpicid'} = 0;
     }
     
diff -r 3cb76b9d702a -r 9ec64bf149c0 htdocs/manage/moodthemes.bml
--- a/htdocs/manage/moodthemes.bml	Mon Jul 26 17:18:48 2010 -0500
+++ b/htdocs/manage/moodthemes.bml	Mon Jul 26 17:47:46 2010 -0500
@@ -275,7 +275,7 @@ body<=
                 foreach ( keys %update ) {
                     delete $update{$_} if $u->{$_} eq $update{$_};
                 }
-                LJ::update_user( $u, \%update );
+                $u->update_self( \%update );
                 return BML::redirect( $self_uri );
             }
         } elsif ( $POST{isnew} != 1 ) {
diff -r 3cb76b9d702a -r 9ec64bf149c0 htdocs/manage/profile/index.bml
--- a/htdocs/manage/profile/index.bml	Mon Jul 26 17:18:48 2010 -0500
+++ b/htdocs/manage/profile/index.bml	Mon Jul 26 17:47:46 2010 -0500
@@ -642,7 +642,7 @@ body<=
 
         my $save_rv = LJ::Setting->save_all($remote, \%POST, \@settings);
 
-        LJ::update_user($u, \%update);
+        $u->update_self( \%update );
 
         ### change any of the userprops ?
         {
diff -r 3cb76b9d702a -r 9ec64bf149c0 htdocs/register.bml
--- a/htdocs/register.bml	Mon Jul 26 17:18:48 2010 -0500
+++ b/htdocs/register.bml	Mon Jul 26 17:47:46 2010 -0500
@@ -116,7 +116,7 @@ body<=
         }
      }
 
-     LJ::update_user($u, { status => 'A' });
+     $u->update_self( { status => 'A' } );
      $u->update_email_alias;
      LJ::Hooks::run_hook('email_verified', $u);
 
diff -r 3cb76b9d702a -r 9ec64bf149c0 t/console-changecommunityadmin.t
--- a/t/console-changecommunityadmin.t	Mon Jul 26 17:18:48 2010 -0500
+++ b/t/console-changecommunityadmin.t	Mon Jul 26 17:47:46 2010 -0500
@@ -35,11 +35,11 @@ is($run->("change_community_admin " . $c
 is($run->("change_community_admin " . $comm->user . " " . $comm2->user),
    "error: New owner doesn't exist or isn't a person account.");
 
-LJ::update_user($u, { 'status' => 'T' });
+$u->update_self( { status => 'T' } );
 is($run->("change_community_admin " . $comm->user . " " . $u->user),
    "error: New owner's email address isn't validated.");
 
-LJ::update_user($u, { 'status' => 'A' });
+$u->update_self( { status => 'A' } );
 is($run->("change_community_admin " . $comm->user . " " . $u->user),
    "success: Transferred maintainership of '" . $comm->user . "' to '" . $u->user . "'.");
 
diff -r 3cb76b9d702a -r 9ec64bf149c0 t/console-changejournaltype.t
--- a/t/console-changejournaltype.t	Mon Jul 26 17:18:48 2010 -0500
+++ b/t/console-changejournaltype.t	Mon Jul 26 17:47:46 2010 -0500
@@ -11,7 +11,7 @@ plan tests => 7;
 
 my $u = temp_user();
 my $u2 = temp_user();
-LJ::update_user($u2, { status => 'A' });
+$u2->update_self( { status => 'A' } );
 $u2 = LJ::load_user($u2->user);
 
 my $comm = temp_comm();
diff -r 3cb76b9d702a -r 9ec64bf149c0 t/console-finduser.t
--- a/t/console-finduser.t	Mon Jul 26 17:18:48 2010 -0500
+++ b/t/console-finduser.t	Mon Jul 26 17:47:46 2010 -0500
@@ -21,7 +21,7 @@ is($run->("finduser " . $u->user),
    "error: You are not authorized to run this command.");
 $u->grant_priv("finduser");
 
-LJ::update_user($u, { 'email' => $u->user . "\@$LJ::DOMAIN", 'status' => 'A' });
+$u->update_self( { email => $u->user . "\@$LJ::DOMAIN", status => 'A' } );
 $u = LJ::load_user($u->user);
 
 is($run->("finduser " . $u->user),
diff -r 3cb76b9d702a -r 9ec64bf149c0 t/esn-journalnewentry.t
--- a/t/esn-journalnewentry.t	Mon Jul 26 17:18:48 2010 -0500
+++ b/t/esn-journalnewentry.t	Mon Jul 26 17:47:46 2010 -0500
@@ -143,8 +143,7 @@ sub test_esn_flow {
     my $u2 = temp_user();
 
     # need a community for $u1 and $u2 to play in
-    my $ucomm = temp_user();
-    LJ::update_user($ucomm, { journaltype => 'C' });
+    my $ucomm = temp_comm();
 
     LJ::add_friend($u1, $u2); # make u1 friend u2
     $cv->($u1, $u2, $ucomm);
diff -r 3cb76b9d702a -r 9ec64bf149c0 t/user-infoshow-migrate.t
--- a/t/user-infoshow-migrate.t	Mon Jul 26 17:18:48 2010 -0500
+++ b/t/user-infoshow-migrate.t	Mon Jul 26 17:47:46 2010 -0500
@@ -17,7 +17,7 @@ sub new_temp_user {
     ok(LJ::isu($u), 'temp user created');
 
     # force it to Y, since we're testing migration here
-    LJ::update_user($u, { 'allow_infoshow' => "Y"});
+    $u->update_self( { allow_infoshow => 'Y' } );
     $u->clear_prop("opt_showlocation");
     $u->clear_prop("opt_showbday");
 
@@ -39,7 +39,7 @@ sub run_tests {
             my $u = new_temp_user();
             if ($mode eq 'off') {
                 my $uid = $u->{userid};
-                LJ::update_user($u, { allow_infoshow => 'N' });
+                $u->update_self( { allow_infoshow => 'N' } );
                 is($u->{allow_infoshow}, 'N', 'allow_infoshow set to N');
 
                 my $temp_var = $getter->($u);
diff -r 3cb76b9d702a -r 9ec64bf149c0 t/userloading.t
--- a/t/userloading.t	Mon Jul 26 17:18:48 2010 -0500
+++ b/t/userloading.t	Mon Jul 26 17:47:46 2010 -0500
@@ -39,11 +39,11 @@ memcache_stress(sub {
     my $name;
     {
         $name = "My name is " . rand();
-        LJ::update_user($u, { name => $name });
+        $u->update_self( { name => $name } );
         is($u->{name}, $name, "name changed after update");
 
         $name = "My name is " . rand();
-        LJ::update_user($u, { raw => "name='$name'" });
+        $u->update_self( { raw => "name='$name'" } );
         is($u->{name}, $name, "name changed after raw update");
     }
 
--------------------------------------------------------------------------------