alf (red_alf) wrote in changelog,
alf
red_alf
changelog

[livejournal] r18225: LJSUP-7883: Fix error in trim function f...

Committer: afedorov
LJSUP-7883: Fix error in trim function for widget "Recent Comments"

U   trunk/cgi-bin/LJ/Comment.pm
U   trunk/cgi-bin/LJ/User.pm
U   trunk/cgi-bin/LJ/Widget/RecentComments.pm
U   trunk/cgi-bin/ljtextutil.pl
Modified: trunk/cgi-bin/LJ/Comment.pm
===================================================================
--- trunk/cgi-bin/LJ/Comment.pm	2011-02-07 08:38:04 UTC (rev 18224)
+++ trunk/cgi-bin/LJ/Comment.pm	2011-02-07 09:44:54 UTC (rev 18225)
@@ -862,6 +862,11 @@
     return $self->state eq 'D' ? 1 : 0;
 }
 
+sub is_spam {
+    my $self = shift;
+    return $self->state eq 'B' ? 1 : 0;
+}
+
 sub is_frozen {
     my $self = shift;
     return $self->state eq 'F' ? 1 : 0;

Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2011-02-07 08:38:04 UTC (rev 18224)
+++ trunk/cgi-bin/LJ/User.pm	2011-02-07 09:44:54 UTC (rev 18225)
@@ -2212,7 +2212,7 @@
             "SELECT jtalkid, nodetype, nodeid, parenttalkid, ".
             "       posterid, UNIX_TIMESTAMP(datepost) as 'datepostunix', state ".
             "FROM talk2 ".
-            "WHERE journalid=? AND state <> 'D' " .
+            "WHERE journalid=? AND (state <> 'D' AND state <> 'B') " .
             "ORDER BY jtalkid DESC ".
             "LIMIT $max_fetch"
         ); 

Modified: trunk/cgi-bin/LJ/Widget/RecentComments.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/RecentComments.pm	2011-02-07 08:38:04 UTC (rev 18224)
+++ trunk/cgi-bin/LJ/Widget/RecentComments.pm	2011-02-07 09:44:54 UTC (rev 18225)
@@ -3,6 +3,7 @@
 use strict;
 use base qw(LJ::Widget);
 use Carp qw(croak);
+use LJ::Text;
 
 sub need_res {
     return qw( stc/widgets/recentcomments.css );
@@ -43,7 +44,7 @@
 
         # load the comment
         my $comment = LJ::Comment->new($u, jtalkid => $row->{jtalkid});
-        next if $comment->is_deleted;
+        next if $comment->is_deleted || $comment->is_spam;
 
         # load the comment poster
         my $posteru = $comment->poster;
@@ -55,7 +56,7 @@
         my $class_name = ($ct == scalar(@comments) - 1) ? "last" : "";
 
         my $subject = $entry->subject_text ? $entry->subject_text : $class->ml('widget.recentcomments.nosubject');
-        my $body_part = substr($comment->body_text, 0, 250) . "&nbsp;";
+        my $body_part = LJ::Text->truncate_to_word_with_ellipsis( 'str'=>$comment->body_text, 'chars'=>150 ) . "&nbsp;";
 
         # prevent BML tags interpretation inside comment subject/body
         $subject =~ s/<\?/&lt;?/g;

Modified: trunk/cgi-bin/ljtextutil.pl
===================================================================
--- trunk/cgi-bin/ljtextutil.pl	2011-02-07 08:38:04 UTC (rev 18224)
+++ trunk/cgi-bin/ljtextutil.pl	2011-02-07 09:44:54 UTC (rev 18225)
@@ -437,6 +437,7 @@
 }
 
 # trim string, but not truncate in middle of the word
+# Deprecated. Use LJ::Text->truncate_to_word_with_ellipsis
 sub trim_at_word
 {
     my ($text, $char_max) = @_;

Tags: livejournal, pl, pm, red_alf
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments