Pass in explicitly the option to only update the db if the value has
changed, instead of guessing (guessing may not catch cases where we had just
not passed in a value because we don't have it on hand)
Patch by kareila.
diffs (36 lines):
diff -r a1367eecddb9 -r 95226a1cdf3a cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm Wed Jul 21 20:38:10 2010 -0700
+++ b/cgi-bin/LJ/User.pm Thu Jul 22 09:47:11 2010 -0700
@@ -2784,9 +2784,10 @@ sub remove_from_class {
# or also accepts a hashref of propname keys and corresponding values.
# Returns boolean indicating success or failure.
sub set_prop {
- my ( $u, $prop, $value ) = @_;
+ my ( $u, $prop, $value, $opts ) = @_;
my $userid = $u->userid + 0;
my $hash = ref $prop eq "HASH" ? $prop : { $prop => $value };
+ $opts ||= {};
my %action; # $table -> {"replace"|"delete"} -> [ "($propid, $qvalue)" |
propid ]
my %multihomed; # { $propid => $value }
@@ -2816,7 +2817,7 @@ sub set_prop {
$table = 'userpropblob' if $p->{datatype} eq 'blobchar';
# only assign db for update action if value has changed
- unless ( exists $u->{$propname} && $value eq $u->{$propname} ) {
+ unless ( $opts->{skip_db} && $value eq $u->{$propname} ) {
my $db = $action{$table}->{db} ||= (
$table !~ m{userprop(lite2|blob)}
? LJ::get_db_writer() # global
diff -r a1367eecddb9 -r 95226a1cdf3a htdocs/manage/profile/index.bml
--- a/htdocs/manage/profile/index.bml Wed Jul 21 20:38:10 2010 -0700
+++ b/htdocs/manage/profile/index.bml Thu Jul 22 09:47:11 2010 -0700
@@ -709,7 +709,7 @@ body<=
$eff_val = "" unless $eff_val;
$prop{$uprop} = $eff_val;
}
- $u->set_prop( \%prop );
+ $u->set_prop( \%prop, undef, { skip_db => 1 } );
# location or bday could've changed... (who cares about checking
exactly)
$u->invalidate_directory_record;
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog