Change calls from LJ::set_userprop( $u, ... ) to $u->set_prop( ... ).
Tweak $u->set_prop so that it accepts hashref arguments, to be able to set
multiple props at once.
Patch by kareila.
diffs (230 lines):
diff -r 4b3858085fc1 -r df00147d4a72 bin/renameuser.pl
--- a/bin/renameuser.pl Sat Jun 26 10:42:52 2010 -0500
+++ b/bin/renameuser.pl Mon Jun 28 15:33:29 2010 +0800
@@ -101,7 +101,7 @@ unless (rename_user("lj_swap_$swapnum",
my $fromu_r = $fromu ? $fromu->prop( 'renamedto' ) : undef;
if ( $fromu_r && $fromu_r ne $to) {
print "Setting redirection: $from => $to\n";
- unless (LJ::set_userprop($fromu, 'renamedto' => $to)) {
+ unless ( $fromu->set_prop( 'renamedto' => $to ) ) {
print "Error setting 'renamedto' userprop for $from\n";
exit 1;
}
@@ -111,7 +111,7 @@ unless (rename_user("lj_swap_$swapnum",
my $tou = LJ::load_user($to, 'force');
if ( $tou && $tou->prop( 'renamedto' ) ) {
print "Removing redirection for user: $to\n";
- unless (LJ::set_userprop($tou, 'renamedto' => undef)) {
+ unless ( $tou->set_prop( 'renamedto' => undef ) ) {
print "Error setting 'renamedto' userprop for $to\n";
exit 1;
}
diff -r 4b3858085fc1 -r df00147d4a72 cgi-bin/LJ/SynSuck.pm
--- a/cgi-bin/LJ/SynSuck.pm Sat Jun 26 10:42:52 2010 -0500
+++ b/cgi-bin/LJ/SynSuck.pm Mon Jun 28 15:33:29 2010 +0800
@@ -109,7 +109,7 @@ sub get_content {
# same request
delay($userid, 3*60, "parseerror");
- LJ::set_userprop($userid, "rssparseerror", $res->status_line());
+ $syn_u->set_prop( "rssparseerror", $res->status_line() ) if $syn_u;
return;
}
@@ -166,8 +166,9 @@ sub process_content {
print "Parse error! $error\n" if $verbose;
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);
+ $error =~ s/^\n//; # cleanup of newline at the beginning of the line
+ my $syn_u = LJ::load_user( $user );
+ $syn_u->set_prop( "rssparseerror", $error ) if $syn_u;
return;
}
@@ -434,12 +435,12 @@ sub process_content {
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;
diff -r 4b3858085fc1 -r df00147d4a72 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm Sat Jun 26 10:42:52 2010 -0500
+++ b/cgi-bin/LJ/User.pm Mon Jun 28 15:33:29 2010 +0800
@@ -2718,7 +2718,10 @@ sub set_prop {
sub set_prop {
my ($u, $prop, $value) = @_;
return 0 unless LJ::set_userprop($u, $prop, $value); # FIXME: use
exceptions
- $u->{$prop} = $value;
+ return $u->{$prop} = $value unless ref $prop;
+ # handle hashref arguments
+ $u->{$_} = $prop->{$_} foreach keys %$prop;
+ return 1;
}
diff -r 4b3858085fc1 -r df00147d4a72 cgi-bin/ljprotocol.pl
--- a/cgi-bin/ljprotocol.pl Sat Jun 26 10:42:52 2010 -0500
+++ b/cgi-bin/ljprotocol.pl Mon Jun 28 15:33:29 2010 +0800
@@ -1438,7 +1438,7 @@ sub postevent
$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
@@ -1759,7 +1759,7 @@ sub editevent
if ($u->{'userid'} == $uowner->{'userid'}) {
$u->preload_props( { use_master => 1 }, "newesteventtime" );
if ($u->{'newesteventtime'} eq $oldevent->{'eventtime'}) {
- LJ::set_userprop($u, "newesteventtime", undef);
+ $u->set_prop( "newesteventtime", undef );
}
}
@@ -1778,7 +1778,7 @@ sub editevent
# clear their duplicate protection, so they can later repost
# what they just deleted. (or something... probably rare.)
- LJ::set_userprop($u, "dupsig_post", undef);
+ $u->set_prop( "dupsig_post", undef );
$uowner->clear_daycounts( $qallowmask || $req->{security} );
# pass the delete
@@ -1883,11 +1883,11 @@ sub editevent
# did they change the time?
if ($eventtime ne $oldevent->{eventtime}) {
# the newesteventtime is this event's new time.
- LJ::set_userprop($u, "newesteventtime", $eventtime);
+ $u->set_prop( "newesteventtime", $eventtime );
} elsif (!$curprops{$itemid}->{opt_backdated} &&
$req->{props}{opt_backdated}) {
# otherwise, if they set the backdated flag,
# then we no longer know the newesteventtime.
- LJ::set_userprop($u, "newesteventtime", undef);
+ $u->set_prop( "newesteventtime", undef );
}
}
@@ -2167,9 +2167,9 @@ sub getevents
# 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;
diff -r 4b3858085fc1 -r df00147d4a72 htdocs/community/manage.bml
--- a/htdocs/community/manage.bml Sat Jun 26 10:42:52 2010 -0500
+++ b/htdocs/community/manage.bml Mon Jun 28 15:33:29 2010 +0800
@@ -159,13 +159,12 @@ body<=
# save any changes
if (LJ::did_post()) {
- unless (LJ::check_form_auth()) {
- $ret .= "<?h1 $ML{'Error'} h1?><?p $ML{'error.invalidform'} p?>";
- return $ret;
- }
+ unless ( LJ::check_form_auth() ) {
+ $ret .= "<?h1 $ML{'Error'} h1?><?p $ML{'error.invalidform'} p?>";
+ return $ret;
+ }
- my $mod_emails = $POST{modemail} ? 1 : 0;
- LJ::set_userprop($remote, 'opt_nomodemail', $mod_emails ? undef : 1);
+ $remote->set_prop( 'opt_nomodemail', $POST{modemail} ? undef : 1 );
}
my $mod_emails = $remote->prop("opt_nomodemail") ? 0 : 1;
diff -r 4b3858085fc1 -r df00147d4a72 htdocs/community/settings.bml
--- a/htdocs/community/settings.bml Sat Jun 26 10:42:52 2010 -0500
+++ b/htdocs/community/settings.bml Mon Jun 28 15:33:29 2010 +0800
@@ -165,8 +165,8 @@ body<=
my $moderated = $POST{moderated} ? 1 : 0;
my $hidejoinpostlink = $POST{showjoinpostlink} ? 0 : 1;
- LJ::set_userprop($cu, 'nonmember_posting', $nonmember_posting);
- LJ::set_userprop($cu, 'moderated', $moderated);
+ $cu->set_prop( { nonmember_posting => $nonmember_posting,
+ moderated => $moderated } );
$cu->hide_join_post_link( $hidejoinpostlink );
$cu->posting_guidelines_entry( $POST{'postingguidelinesentry'} );
diff -r 4b3858085fc1 -r df00147d4a72 htdocs/customize/advanced/styles.bml
--- a/htdocs/customize/advanced/styles.bml Sat Jun 26 10:42:52 2010 -0500
+++ b/htdocs/customize/advanced/styles.bml Mon Jun 28 15:33:29 2010 +0800
@@ -115,8 +115,8 @@ _c?>
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::Hooks::run_hooks('apply_theme', $u);
return BML::redirect("styles$getextra");
}
diff -r 4b3858085fc1 -r df00147d4a72 htdocs/manage/domain.bml
--- a/htdocs/manage/domain.bml Sat Jun 26 10:42:52 2010 -0500
+++ b/htdocs/manage/domain.bml Mon Jun 28 15:33:29 2010 +0800
@@ -99,10 +99,10 @@ body<=
}
# change any of the userprops ?
- foreach my $uprop (keys %uprop) {
- next if $POST{$uprop} eq $u->{$uprop};
- LJ::set_userprop($u, $uprop, $uprop{$uprop});
+ foreach ( keys %uprop ) {
+ delete $uprop{$_} if $POST{$_} eq $u->{$_};
}
+ $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?>";
diff -r 4b3858085fc1 -r df00147d4a72 htdocs/manage/emailpost.bml
--- a/htdocs/manage/emailpost.bml Sat Jun 26 10:42:52 2010 -0500
+++ b/htdocs/manage/emailpost.bml Mon Jun 28 15:33:29 2010 +0800
@@ -339,12 +339,12 @@ body<=
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->set_prop( $prop, undef );
}
}
- LJ::set_userprop($u, "emailpost_pin", $pin);
+ $u->set_prop( "emailpost_pin", $pin );
LJ::Setting::EmailPosting->email_helpmessage( $u, $_ )
foreach @send_helpmessage;
diff -r 4b3858085fc1 -r df00147d4a72 htdocs/manage/pubkey.bml
--- a/htdocs/manage/pubkey.bml Sat Jun 26 10:42:52 2010 -0500
+++ b/htdocs/manage/pubkey.bml Mon Jun 28 15:33:29 2010 +0800
@@ -67,7 +67,7 @@ body<=
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
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog