Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r17806: LJSUP-7462 (refactor userprops)

Committer: ailyin
LJSUP-7462 (refactor userprops)
U   trunk/bin/renameuser.pl
U   trunk/cgi-bin/Apache/LiveJournal/Interface/FotoBilder.pm
U   trunk/cgi-bin/LJ/SynSuck.pm
U   trunk/cgi-bin/LJ/User/Rename.pm
U   trunk/cgi-bin/ljprotocol.pl
U   trunk/htdocs/community/manage.bml
U   trunk/htdocs/community/settings.bml
U   trunk/htdocs/customize/advanced/styles.bml
U   trunk/htdocs/manage/comments/index.bml
U   trunk/htdocs/manage/domain.bml
U   trunk/htdocs/manage/emailpost.bml
U   trunk/htdocs/manage/profile/index.bml
U   trunk/htdocs/manage/pubkey.bml
U   trunk/htdocs/utf8convert.bml
Modified: trunk/bin/renameuser.pl
===================================================================
--- trunk/bin/renameuser.pl	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/bin/renameuser.pl	2010-11-29 04:03:57 UTC (rev 17806)
@@ -96,10 +96,7 @@
     LJ::load_user_props($fromu, 'renamedto');
     if ($fromu->{renamedto} && $fromu->{renamedto} ne $to) {
         print "Setting redirection: $from => $to\n";
-        unless (LJ::set_userprop($fromu, 'renamedto' => $to)) {
-            print "Error setting 'renamedto' userprop for $from\n";
-            exit 1;
-        }
+        $from_u->set_prop( 'renamedto' => $to );
     }
 
     # if the $to user had redirection, they shouldn't anymore

Modified: trunk/cgi-bin/Apache/LiveJournal/Interface/FotoBilder.pm
===================================================================
--- trunk/cgi-bin/Apache/LiveJournal/Interface/FotoBilder.pm	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/cgi-bin/Apache/LiveJournal/Interface/FotoBilder.pm	2010-11-29 04:03:57 UTC (rev 17806)
@@ -125,7 +125,7 @@
                         undef, LJ::get_blob_domainid('fotobilder'),
                         $used, $u->{'userid'});
 
-    LJ::set_userprop($u, "fb_num_pubpics", $POST->{'pub_pics'});
+    $u->set_prop( 'fb_num_pubpics' => $POST->{'pub_pics'} );
 
     return {
         status => ($result ? 1 : 0),

Modified: trunk/cgi-bin/LJ/SynSuck.pm
===================================================================
--- trunk/cgi-bin/LJ/SynSuck.pm	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/cgi-bin/LJ/SynSuck.pm	2010-11-29 04:03:57 UTC (rev 17806)
@@ -99,7 +99,7 @@
         # same request
         delay($userid, 3*60, "parseerror");
 
-        LJ::set_userprop($userid, "rssparseerror", $res->status_line());
+        $syn_u->set_prop( 'rssparseerror' => $res->status_line );
         return;
     }
 
@@ -119,6 +119,8 @@
     my ($user, $userid, $synurl, $lastmod, $etag, $readers) =
         map { $urow->{$_} } qw(user userid synurl lastmod etag numreaders);
 
+    my $su = LJ::load_userid($userid);
+
     my $dbh = LJ::get_db_writer();
 
     # WARNING: blatant XML spec violation ahead...
@@ -157,7 +159,7 @@
         delay($userid, 3*60, "parseerror");
         $error =~ s! at /.*!!;
         $error =~ s/^\n//; # cleanup of newline at the beggining of the line
-        LJ::set_userprop($userid, "rssparseerror", $error);
+        $su->set_prop( 'rssparseerror' => $error );
         return;
     }
 
@@ -173,8 +175,6 @@
 
     # delete existing items older than the age which can show on a
     # friends view.
-    my $su = LJ::load_userid($userid);
-
     my $udbh = LJ::get_cluster_master($su);
     unless ($udbh) {
         return delay($userid, 15, "nodb");
@@ -404,12 +404,12 @@
         if (defined $title && $title ne $su->{'name'}) {
             $title =~ s/[\n\r]//g;
             LJ::update_user($su, { name => $title });
-            LJ::set_userprop($su, "urlname", $title);
+            $su->set_prop( 'urlname' => $title );
         }
 
         my $link = $feed->{'link'};
         if ($link && $link ne $su->{'url'}) {
-            LJ::set_userprop($su, "url", $link);
+            $su->set_prop( 'url' => $link );
         }
 
         my $bio = $su->bio;

Modified: trunk/cgi-bin/LJ/User/Rename.pm
===================================================================
--- trunk/cgi-bin/LJ/User/Rename.pm	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/cgi-bin/LJ/User/Rename.pm	2010-11-29 04:03:57 UTC (rev 17806)
@@ -261,7 +261,10 @@
 
         if ($u->{journaltype} ne 'P' || $opts->{'opt_redir'}) {
             LJ::update_user($u_old_username, { raw => "journaltype='R', statusvis='R', statusvisdate=NOW()" });
-            LJ::set_userprop($dbh, $u_old_username, "renamedto", $to); # 'from' will point to 'to'
+
+            # 'from' will point to 'to':
+            $u_old_username->set_prop( 'renamedto' => $to );
+
             if ($u->prop('renamedto')) {
                 $u->set_prop('renamedto', undef) if $u->prop('renamedto') eq $from; # safeness against circular redirection
             }

Modified: trunk/cgi-bin/ljprotocol.pl
===================================================================
--- trunk/cgi-bin/ljprotocol.pl	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/cgi-bin/ljprotocol.pl	2010-11-29 04:03:57 UTC (rev 17806)
@@ -1655,7 +1655,7 @@
         $set_userprop{"newesteventtime"} = $eventtime
             if $posterid == $ownerid and not $req->{'props'}->{'opt_backdated'} and not $time_was_faked;
 
-        LJ::set_userprop($u, \%set_userprop);
+        $u->set_prop(\%set_userprop);
     }
 
     # end duplicate locking section
@@ -1988,7 +1988,7 @@
         if ($u->{'userid'} == $uowner->{'userid'}) {
             LJ::load_user_props($u, { use_master => 1 }, "newesteventtime");
             if ($u->{'newesteventtime'} eq $oldevent->{'eventtime'}) {
-                LJ::set_userprop($u, "newesteventtime", undef);
+                $u->clear_prop('newesteventtime');
             }
         }
 
@@ -2012,7 +2012,7 @@
 
         # clear their duplicate protection, so they can later repost
         # what they just deleted.  (or something... probably rare.)
-        LJ::set_userprop($poster, "dupsig_post", undef) if $poster;
+        $poster->clear_prop('dupsig_post') if $poster;
 
         my $res = {
             'itemid' => $itemid,
@@ -2114,11 +2114,11 @@
             if (!$curprops{$itemid}->{opt_backdated} && $req->{props}{opt_backdated}) {
                 # if they set the backdated flag, then we no longer know
                 # the newesteventtime.
-                LJ::set_userprop($u, "newesteventtime", undef);
+                $u->clear_prop('newesteventtime');
             } elsif ($eventtime ne $oldevent->{eventtime}) {
                 # otherwise, if they changed time on this event,
                 # the newesteventtime is this event's new time.
-                LJ::set_userprop($u, "newesteventtime", $eventtime);
+                $u->set_prop( 'newesteventtime' => $eventtime );
             }
         }
 
@@ -2418,9 +2418,9 @@
                 # their client is busted.  (doesn't understand syncitems semantics)
                 return fail($err,406);
             }
-            LJ::set_userprop($u, $pname,
-                             join('/', map { $_, $reqs{$_} }
-                                  sort { $b <=> $a } keys %reqs));
+            $u->set_prop( $pname => join( '/', map { $_ => $reqs{$_} }
+                                               sort { $b <=> $a }
+                                               keys %reqs ) );
         }
 
         my %item;

Modified: trunk/htdocs/community/manage.bml
===================================================================
--- trunk/htdocs/community/manage.bml	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/htdocs/community/manage.bml	2010-11-29 04:03:57 UTC (rev 17806)
@@ -155,6 +155,7 @@
     }
 
      my $mod_emails = $POST{modemail} ? 1 : 0;
+     $remote->set_prop( 'opt_nomodemail' => $mod_emails ? undef : 1 );
      LJ::set_userprop($remote, 'opt_nomodemail', $mod_emails ? undef : 1);
  }
 

Modified: trunk/htdocs/community/settings.bml
===================================================================
--- trunk/htdocs/community/settings.bml	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/htdocs/community/settings.bml	2010-11-29 04:03:57 UTC (rev 17806)
@@ -154,8 +154,8 @@
 
             my $moderated = ($POST{moderated} =~ /^[NAF]$/) ? $POST{moderated} : 'F';
 
-            LJ::set_userprop($cu, 'nonmember_posting', $nonmember_posting);
-            LJ::set_userprop($cu, 'moderated', $moderated);
+            $cu->set_prop({ 'nonmember_posting' => $nonmember_posting,
+                            'moderated'         => $moderated, });
             if ($moderated eq 'F') {
                 my $userlist = LJ::SpamFilter->get_only_user_list($cu);
                 LJ::SpamFilter->set_default_user_list($cu) unless scalar @$userlist;

Modified: trunk/htdocs/customize/advanced/styles.bml
===================================================================
--- trunk/htdocs/customize/advanced/styles.bml	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/htdocs/customize/advanced/styles.bml	2010-11-29 04:03:57 UTC (rev 17806)
@@ -102,8 +102,8 @@
             return "<b>$ML{'Error'}</b> $ML{'error.invalidform'}" unless LJ::check_form_auth();
 
             # save to db and update user object
-            LJ::set_userprop($u, "stylesys", '2');
-            LJ::set_userprop($u, "s2_style", $id);
+            $u->set_prop({ 'stylesys' => 2,
+                           's2_style' => $id, });
             LJ::run_hooks('apply_theme', $u);
             return BML::redirect("styles.bml$getextra");
         }

Modified: trunk/htdocs/manage/comments/index.bml
===================================================================
--- trunk/htdocs/manage/comments/index.bml	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/htdocs/manage/comments/index.bml	2010-11-29 04:03:57 UTC (rev 17806)
@@ -245,7 +245,7 @@
                 my $eff_val = $POST{$uprop};   # effective value, since 0 isn't stored
                 $eff_val = "" unless $eff_val;
                 my $mem_only = $eff_val eq $u->{$uprop};
-                LJ::set_userprop($u, $uprop, $eff_val, $mem_only);
+                $u->set_prop( $uprop => $eff_val, $mem_only );
             }
         }
 

Modified: trunk/htdocs/manage/domain.bml
===================================================================
--- trunk/htdocs/manage/domain.bml	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/htdocs/manage/domain.bml	2010-11-29 04:03:57 UTC (rev 17806)
@@ -78,10 +78,7 @@
         }
 
         # change any of the userprops ?
-        foreach my $uprop (keys %uprop) {
-            next if $POST{$uprop} eq $u->{$uprop};
-            LJ::set_userprop($u, $uprop, $uprop{$uprop});
-        }
+        $u->set_prop(\%uprop);
 
         # tell the user all is well
         return "<?h1 $ML{'.success.head'} h1?><?p Your domain aliasing settings have been updated. p?>";

Modified: trunk/htdocs/manage/emailpost.bml
===================================================================
--- trunk/htdocs/manage/emailpost.bml	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/htdocs/manage/emailpost.bml	2010-11-29 04:03:57 UTC (rev 17806)
@@ -412,12 +412,12 @@
             if ($POST{$prop} && $POST{$prop} ne 'default') {
                 $POST{$prop} = undef if $prop eq 'emailpost_gallery' &&
                                         $POST{$prop} eq 'LJ_emailpost';
-                LJ::set_userprop($u, $prop, $POST{$prop});
+                $u->set_prop( $prop => $POST{$prop} );
             } else {
-                LJ::set_userprop($u, $prop, undef);
+                $u->clear_prop($prop);
             }
         }
-        LJ::set_userprop($u, "emailpost_pin", $pin);
+        $u->set_prop( 'emailpost_pin' => $pin );
 
         my $ret;
         $ret .= "<?h1 $ML{'.success.header'} h1?>";

Modified: trunk/htdocs/manage/profile/index.bml
===================================================================
--- trunk/htdocs/manage/profile/index.bml	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/htdocs/manage/profile/index.bml	2010-11-29 04:03:57 UTC (rev 17806)
@@ -818,12 +818,8 @@
                 if $u->gizmo_account ne $POST{'gizmo'};
 
             # set userprops
-            foreach my $uprop (@uprops) {
-                my $eff_val = $POST{$uprop};   # effective value, since 0 isn't stored
-                $eff_val = "" unless $eff_val;
-                my $mem_only = $eff_val eq $u->{$uprop};
-                LJ::set_userprop($u, $uprop, $eff_val, $mem_only);
-            }
+            my %props_update = map { $_ => $POST{$_} } @uprops;
+            $u->set_prop(\%props_update);
 
             LJ::run_hook('save_extra_profile_fields', $u);
 

Modified: trunk/htdocs/manage/pubkey.bml
===================================================================
--- trunk/htdocs/manage/pubkey.bml	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/htdocs/manage/pubkey.bml	2010-11-29 04:03:57 UTC (rev 17806)
@@ -53,7 +53,7 @@
 
         unless (@errors) {
             $key = LJ::trim($key);
-            LJ::set_userprop($u, 'public_key', $key);
+            $u->set_prop( 'public_key' => $key );
 
             # This page shows them their key saved
             # eventually add a confirmation bar on it

Modified: trunk/htdocs/utf8convert.bml
===================================================================
--- trunk/htdocs/utf8convert.bml	2010-11-26 09:05:45 UTC (rev 17805)
+++ trunk/htdocs/utf8convert.bml	2010-11-29 04:03:57 UTC (rev 17806)
@@ -446,8 +446,9 @@
         LJ::load_user_props($u, qw(url urlname));
         foreach my $prop (qw(url urlname)) {
             unless(LJ::is_utf8($u->{$prop})) {
-                convert(\$u->{$prop}, $encid);
-                LJ::set_userprop($u->{'userid'}, $prop, $u->{$prop});
+                my $newval = $u->{$prop};
+                convert(\$newval, $encid);
+                $u->set_prop( $prop => $newval );
                 $message .= "<?p Converted userprop: $prop . p?>";
             }
         }

Tags: andy, bml, livejournal, pl, pm
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments