fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-08-23 10:53 am

[dw-free] Misc warnings in logs related to uninitialized variables when posting a comment

[commit: http://hg.dwscoalition.org/dw-free/rev/1dadbb802d5a]

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

Silence warnings by initializing undef variables to empty strings.

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/LJ/Talk.pm
--------------------------------------------------------------------------------
diff -r 9dc8b94f2d30 -r 1dadbb802d5a cgi-bin/LJ/Talk.pm
--- a/cgi-bin/LJ/Talk.pm	Tue Aug 23 17:32:58 2011 +0800
+++ b/cgi-bin/LJ/Talk.pm	Tue Aug 23 18:53:01 2011 +0800
@@ -326,6 +326,8 @@
 # </LJFUNC>
 sub can_delete {
     my ( $remote, $u, $up, $userpost ) = @_; # remote, journal, posting user, commenting user
+    $userpost ||= "";
+
     return 0 unless LJ::isu( $remote );
     return 1 if $remote->user eq $userpost ||
                 $remote->user eq ( ref $u ? $u->user : $u ) ||
@@ -3527,13 +3529,14 @@
     $form->{'subject'} = LJ::text_trim($form->{'subject'}, 100, 100);
 
     my $subjecticon = "";
-    if ($form->{'subjecticon'} ne "none" && $form->{'subjecticon'} ne "") {
-        $subjecticon = LJ::trim(lc($form->{'subjecticon'}));
+    my $form_subjecticon = $form->{'subjecticon'} || "";
+    if ( $form_subjecticon ne "none" && $form_subjecticon ne "" ) {
+        $subjecticon = LJ::trim( lc( $form_subjecticon ) );
     }
 
     # figure out whether to post this comment screened
     my $state = 'A';
-    my $screening = LJ::Talk::screening_level($journalu, $ditemid >> 8);
+    my $screening = LJ::Talk::screening_level($journalu, $ditemid >> 8) || "";
     if (!$form->{editid} && ($screening eq 'A' ||
         ($screening eq 'R' && ! $up) ||
         ($screening eq 'F' && !($up && $journalu->trusts_or_has_member( $up ))))) {
@@ -3681,13 +3684,14 @@
 sub post_comment {
     my ( $entryu, $journalu, $comment, $parent, $item, $errref, $unscreen_parent ) = @_;
 
+    my $parent_state = $parent->{state} || "";
     # unscreen the parent comment if needed
-    if ( $parent->{state} eq 'S' && $unscreen_parent ) {
+    if ( $parent_state eq 'S' && $unscreen_parent ) {
         # if parent comment is screened and we got this far, the user has the permission to unscreen it
         # in this case the parent comment needs to be unscreened and the comment posted as normal
         LJ::Talk::unscreen_comment($journalu, $item->{itemid}, $parent->{talkid});
         $parent->{state} = 'A';
-    } elsif ( $parent->{state} eq 'S' ) {
+    } elsif ( $parent_state eq 'S' ) {
         # if the parent comment is screened and the unscreen option was not selected, we also want the
         # reply to be posted as screened
         $comment->{state} = 'S';
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org