[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
exor674.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=1844
Allow sticky entry to be cleared, and validate the ditemid.
Patch by
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' );
}
--------------------------------------------------------------------------------
