madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r22573: LJSUP-13203: Problem with inbox messages...

Committer: sbelyaev
LJSUP-13203: Problem with inbox messages when original post has been deleted.
U   trunk/cgi-bin/LJ/Event/JournalNewRepost.pm
Modified: trunk/cgi-bin/LJ/Event/JournalNewRepost.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/JournalNewRepost.pm	2012-08-04 20:25:36 UTC (rev 22572)
+++ trunk/cgi-bin/LJ/Event/JournalNewRepost.pm	2012-08-06 08:27:46 UTC (rev 22573)
@@ -39,12 +39,14 @@
 sub poster {
     my ($self) = @_;
     my $entry  = $self->entry;
+    return unless $entry;
 
     return $entry->poster;
 }
 
 sub posterid {
     my $self = shift;
+    return unless $self->poster;
 
     return $self->poster->userid;
 }
@@ -53,13 +55,15 @@
 sub journal {
     my ($self) = @_;
     my $entry  = $self->entry;
+    return unless $entry;
 
     return $entry->journal;
 }
 
 sub journalid {
     my ($self) = @_;
-    my $entry  = $self->entry; 
+    my $entry  = $self->entry;
+    return unless $entry;
 
     return $entry->journalid;
 }
@@ -71,7 +75,6 @@
 
 sub reposterid {
     my ($self) = @_;
-
     return $self->u->userid;
 }
 
@@ -127,11 +130,19 @@
     my $entry    = $self->entry;
     my $journal  = $self->journal;
 
+    if (!$entry) {
+        my $ml_string = 'notification.string.usernewrepost.deleted';
+        return LJ::Lang::get_text($lang, $ml_string, undef,
+                                {
+                                    reposter => $self->reposter->display_username,
+                                });
+    }
+
     my $about = $entry->subject_text ? "\"" . $entry->subject_text . "\"" : '';
 
     my $ml_string = $journal->is_community ? 'notification.string.usernewrepost_comm' : 
                                              'notification.string.usernewrepost';
-
+                             
     return LJ::Lang::get_text($lang, $ml_string, undef,
                         {
                             reposter      => $self->reposter->display_username,
@@ -146,8 +157,10 @@
     my ($self, $u, $opt) = @_;
     my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
 
-    my $entry    = $self->entry;
-    my $journalu = $self->journal;
+    my $entry     = $self->entry;
+    return unless $entry;
+
+    my $journalu  = $self->journal;
     my $ml_string = $journalu->is_community ? 'notification.sms.usernewrepost_comm' : 
                                               'notification.sms.usernewrepost';
 
@@ -193,7 +206,16 @@
     my $lang    = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
     my $entry   = $self->entry;
     my $journal = $self->journal;
-    return "(Invalid entry)" unless $entry && $entry->valid;
+
+    if (!$entry || !$entry->valid) {
+        my $ml_string = 'notification.string.usernewrepost.deleted';
+        return LJ::Lang::get_text($lang, $ml_string, undef,
+                                {
+                                    reposter => $self->reposter->display_username,
+                                });
+    }
+
+
     my $url = $entry->url;
 
     my $ml_string = $journal->is_community ? 'esn.user_new_repost_community.ashtml' :
@@ -234,8 +256,8 @@
     my ($self, $target) = @_;
     my $entry = $self->entry;
 
-    return undef unless $entry && $entry->valid;
-    return undef unless $entry->visible_to($target);
+    return unless $entry && $entry->valid;
+    return unless $entry->visible_to($target);
 
     return $entry->event_html . $self->as_html_actions;
 }

Tags: livejournal, madeon, pm, sbelyaev
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