Fix issue that was causing the drafts to not be cleared when the entry 
was posted successfully. Set the property name instead of the property value on 
the user object. Fix tests.

        Patch by kareila. 

diffs (65 lines):

diff -r 25863b43f726 -r 217e5f370e56 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm        Mon Jul 19 17:55:31 2010 -0500
+++ b/cgi-bin/LJ/User.pm        Mon Jul 19 21:20:14 2010 -0700
@@ -2816,7 +2816,7 @@ sub set_prop {
         $table = 'userpropblob' if $p->{datatype} eq 'blobchar';
 
         # only assign db for update action if value has changed
-        unless ( $value eq $u->{$propname} ) {
+        unless ( exists $u->{$propname} && $value eq $u->{$propname} ) {
             my $db = $action{$table}->{db} ||= (
                 $table !~ m{userprop(lite2|blob)}
                     ? LJ::get_db_writer()  # global
@@ -2826,17 +2826,17 @@ sub set_prop {
 
         # determine if this is a replacement or a deletion
         if ( defined $value && $value ) {
-            push @{ $action{$table}->{replace} }, [ $p->{id}, $value ];
-        } else {
-            push @{ $action{$table}->{delete} }, $p->{id};
+            push @{ $action{$table}->{replace} }, [ $p->{id}, $value, 
$propname ];
+        } else {
+            push @{ $action{$table}->{delete} }, [ $p->{id}, "", $propname ];
         }
     }
 
     # keep in memcache for 24 hours and update user object in memory
     my $memc = sub {
-        my ( $p, $v ) = @_;
+        my ( $p, $v, $propname ) = @{ $_[0] };
         LJ::MemCache::set( [ $userid, "uprop:$userid:$p" ], $v, 3600 * 24 );
-        $u->{$p} = $v;
+        $u->{$propname} = $v eq "" ? undef : $v;
     };
 
     # Execute prepared actions.
@@ -2848,15 +2848,15 @@ sub set_prop {
                 $db->do( "REPLACE INTO $table (userid, upropid, value) VALUES 
$vals" );
                 die $db->errstr if $db->err;
             }
-            $memc->( $_->[0], $_->[1] ) foreach @$list;
+            $memc->( $_ ) foreach @$list;
         }
         if ( my $list = $action{$table}->{delete} ) {
             if ( $db ) {
-                my $in = join( ',', @$list );
+                my $in = join( ',', map { $_->[0] } @$list );
                 $db->do( "DELETE FROM $table WHERE userid=$userid AND upropid 
IN ($in)" );
                 die $db->errstr if $db->err;
             }
-            $memc->( $_, "" ) foreach @$list;
+            $memc->( $_ ) foreach @$list;
         }
     }
 
diff -r 25863b43f726 -r 217e5f370e56 t/esn-end2end.t
--- a/t/esn-end2end.t   Mon Jul 19 17:55:31 2010 -0500
+++ b/t/esn-end2end.t   Mon Jul 19 21:20:14 2010 -0700
@@ -57,6 +57,7 @@ sub test_esn_flow {
         } else {
             $cv->($u1, $u2, $path);
         }
+        sleep 1;
     }
 }
 
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to