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

[dw-free] fix warnings in poll creation code

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

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

Fix warnings in logs.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/LJ/Poll.pm
  • htdocs/poll/create.bml
--------------------------------------------------------------------------------
diff -r e2cfe30251a5 -r eef4b4d00c30 cgi-bin/LJ/Poll.pm
--- a/cgi-bin/LJ/Poll.pm	Mon Oct 24 19:40:57 2011 +0800
+++ b/cgi-bin/LJ/Poll.pm	Mon Oct 24 19:47:32 2011 +0800
@@ -487,7 +487,7 @@
         }
 
         ##### append stuff to the right place
-        if (length($append))
+        if ( defined $append && length $append )
         {
             if ($iopen) {
                 $iopts{'item'} .= $append;
diff -r e2cfe30251a5 -r eef4b4d00c30 htdocs/poll/create.bml
--- a/htdocs/poll/create.bml	Mon Oct 24 19:40:57 2011 +0800
+++ b/htdocs/poll/create.bml	Mon Oct 24 19:47:32 2011 +0800
@@ -160,9 +160,10 @@
         };
 
         # make sure they don't plug in an outrageous count
-        $POST{'count'} = 0 if $POST{'count'} < 0;
-        $POST{'count'} = $RULES{'elements'}->{'max'}
-            if $POST{'count'} > $RULES{'elements'}->{'max'};
+        my $post_count = $POST{count} || 0;
+        $POST{count} = 0 if $post_count < 0;
+        $POST{count} = $RULES{elements}->{max}
+            if $post_count > $RULES{elements}->{max};
 
         # form properties
         foreach my $it (qw(count name isanon whoview whovote)) {
@@ -291,7 +292,7 @@
 
             # checks if minimum and maximum options for checkboxes are OK
 
-            if ($qrec->{'type'} == 'check') {
+            if ( $qrec->{type} eq 'check' ) {
                 my $checkmin = $qrec->{'checkmin'};
                 if ($checkmin > $num_opts) {
                     $err->{$q}->{'checkmin'} = LJ::Lang::ml( ".error.checkmintoohigh2" );
@@ -325,7 +326,7 @@
                 return unless $adj;
 
                 # swap poll items and error references
-                my $swap = sub { return (@_[1], @_[0]) };
+                my $swap = sub { return ( $_[1], $_[0] ) };
 
                 ($poll->{'pq'}->[$adj], $poll->{'pq'}->[$item]) =
                     $swap->($poll->{'pq'}->[$adj], $poll->{'pq'}->[$item]);
--------------------------------------------------------------------------------