kareila: (Default)
kareila ([personal profile] kareila) wrote in [site community profile] changelog2009-09-25 07:05 pm

[dw-free] Cannot clear sticky entry setting.

[commit: http://hg.dwscoalition.org/dw-free/rev/00ac7af96856]

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

Allow sticky entry to be cleared, and validate the ditemid.

Patch by [personal profile] exor674.

Files modified:
  • cgi-bin/LJ/User.pm
--------------------------------------------------------------------------------
diff -r 099eae6312b4 -r 00ac7af96856 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Fri Sep 25 12:40:53 2009 -0500
+++ b/cgi-bin/LJ/User.pm	Fri Sep 25 14:05:21 2009 -0500
@@ -2210,16 +2210,26 @@ sub sticky_entry {
     my ( $u, $input ) = @_;
 
     if ( defined $input ) {
+        unless ( $input ) {
+            $u->set_prop( sticky_entry => '' );
+            return 1;
+        } 
         #also takes URL
         my $ditemid;
         if ( $input =~ m!/(\d+)\.html! ) {
-            $ditemid = $1
+            $ditemid = $1;
         } elsif ( $input =~ m!(\d+)! ) {
-            $ditemid = $1
+            $ditemid = $1;
         } else {
             return 0;
         }
+        
+        # Validate the entry
+        my $item = LJ::Entry->new( $u, ditemid => $ditemid );
+        return 0 unless $item && $item->valid;
+        
         $u->set_prop( sticky_entry => $ditemid );
+        return 1;
     }
     return $u->prop( 'sticky_entry' );
 }
--------------------------------------------------------------------------------