[dw-free] clean up log messages that appear when global warnings are on
[commit: http://hg.dwscoalition.org/dw-free/rev/a3640a29ac07]
http://bugs.dwscoalition.org/show_bug.cgi?id=3040
Fallback values for unininitialized variables. Some styles cleanup.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3040
Fallback values for unininitialized variables. Some styles cleanup.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/Tags.pm
- cgi-bin/htmlcontrols.pl
- cgi-bin/weblib.pl
- htdocs/tools/endpoints/ctxpopup.bml
-------------------------------------------------------------------------------- diff -r 296aacab97c2 -r a3640a29ac07 cgi-bin/LJ/Tags.pm --- a/cgi-bin/LJ/Tags.pm Sun Oct 03 18:01:08 2010 +0800 +++ b/cgi-bin/LJ/Tags.pm Sun Oct 03 19:03:09 2010 +0800 @@ -236,7 +236,8 @@ sub _get_usertagsmulti { } elsif ($sec & $trust_mask) { $res->{$jid}->{$kwid}->{security}->{protected} += $ct; $res->{$jid}->{$kwid}->{security_level} = 'protected' - unless $res->{$jid}->{$kwid}->{security_level} eq 'public'; + unless $res->{$jid}->{$kwid}->{security_level} && + $res->{$jid}->{$kwid}->{security_level} eq 'public'; } elsif ($sec) { # if $sec is true (>0), and not trust/public, then it's a group(s). but it's # still in the form of a number, and we want to know which group(s) it is. so diff -r 296aacab97c2 -r a3640a29ac07 cgi-bin/htmlcontrols.pl --- a/cgi-bin/htmlcontrols.pl Sun Oct 03 18:01:08 2010 +0800 +++ b/cgi-bin/htmlcontrols.pl Sun Oct 03 19:03:09 2010 +0800 @@ -32,8 +32,8 @@ sub html_datetime my $lang = $opts->{'lang'} || "EN"; my ($yyyy, $mm, $dd, $hh, $nn, $ss); my $ret; - my $name = $opts->{'name'}; - my $id = $opts->{'id'}; + my $name = $opts->{name} || ''; + my $id = $opts->{id} || ''; my $disabled = $opts->{'disabled'} ? 1 : 0; my %extra_opts; @@ -42,67 +42,67 @@ sub html_datetime } if ($opts->{'default'} =~ /^(\d\d\d\d)-(\d\d)-(\d\d)(?: (\d\d):(\d\d):(\d\d))?/) { - ($yyyy, $mm, $dd, $hh, $nn, $ss) = ($1 > 0 ? $1 : "", - $2+0, - $3 > 0 ? $3+0 : "", - $4 > 0 ? $4 : "", - $5 > 0 ? $5 : "", - $6 > 0 ? $6 : ""); + ( $yyyy, $mm, $dd, $hh, $nn, $ss ) = ( $1 > 0 ? $1 : "", + $2+0, + $3 > 0 ? $3+0 : "", + defined $4 && $4 > 0 ? $4 : "", + defined $5 && $5 > 0 ? $5 : "", + defined $6 && $6 > 0 ? $6 : "" ); } - $ret .= html_select({ 'name' => "${name}_mm", - 'id' => "${id}_mm", - 'selected' => $mm, - 'class' => 'select', - 'title' => 'month', - 'disabled' => $disabled, %extra_opts, - }, - map { $_, LJ::Lang::month_long_ml($_) } (1..12)); - $ret .= html_text({ 'name' => "${name}_dd", - 'id' => "${id}_dd", - 'size' => '2', - 'class' => 'text', - 'maxlength' => '2', - 'value' => $dd, - 'title' => 'day', - 'disabled' => $disabled, %extra_opts, - }); - $ret .= html_text({ 'name' => "${name}_yyyy", - 'id' => "${id}_yyyy", - 'size' => '4', - 'class' => 'text', - 'maxlength' => '4', - 'value' => $yyyy, - 'title' => 'year', - 'disabled' => $disabled, %extra_opts, - }); - unless ($opts->{'notime'}) { + $ret .= html_select( { name => "${name}_mm", + id => "${id}_mm", + selected => $mm, + class => 'select', + title => 'month', + disabled => $disabled, %extra_opts, + }, + map { $_, LJ::Lang::month_long_ml($_) } (1..12) ); + $ret .= html_text( { name => "${name}_dd", + id => "${id}_dd", + size => '2', + class => 'text', + maxlength => '2', + value => $dd, + title => 'day', + disabled => $disabled, %extra_opts, + } ); + $ret .= html_text( { name => "${name}_yyyy", + id => "${id}_yyyy", + size => '4', + class => 'text', + maxlength => '4', + value => $yyyy, + title => 'year', + disabled => $disabled, %extra_opts, + } ); + unless ( $opts->{notime} ) { $ret .= ' '; - $ret .= html_text({ 'name' => "${name}_hh", - 'id' => "${id}_hh", - 'size' => '2', - 'maxlength' => '2', - 'value' => $hh, - 'title' => 'hour', - 'disabled' => $disabled, - }) . ':'; - $ret .= html_text({ 'name' => "${name}_nn", - 'id' => "${id}_nn", - 'size' => '2', - 'maxlength' => '2', - 'value' => $nn, - 'title' => 'minutes', - 'disabled' => $disabled, - }); - if ($opts->{'seconds'}) { + $ret .= html_text( { name => "${name}_hh", + id => "${id}_hh", + size => '2', + maxlength => '2', + value => $hh, + title => 'hour', + disabled => $disabled, + } ) . ':'; + $ret .= html_text( { name => "${name}_nn", + id => "${id}_nn", + size => '2', + maxlength => '2', + value => $nn, + title => 'minutes', + disabled => $disabled, + } ); + if ( $opts->{seconds} ) { $ret .= ':'; - $ret .= html_text({ 'name' => "${name}_ss", - 'id' => "${id}_ss", - 'size' => '2', - 'maxlength' => '2', - 'value' => $ss, - 'title' => 'seconds', - 'disabled' => $disabled, - }); + $ret .= html_text( { name => "${name}_ss", + id => "${id}_ss", + size => '2', + maxlength => '2', + value => $ss, + title => 'seconds', + disabled => $disabled, + } ); } } @@ -323,17 +323,19 @@ sub html_text # </LJFUNC> sub html_textarea { - my $opts = shift; + my $opts = $_[0]; - my $disabled = $opts->{'disabled'} ? " disabled='disabled'" : ""; - my $ehtml = $opts->{'noescape'} ? 0 : 1; - my $ret; - $ret .= "<textarea"; + my $disabled = $opts->{disabled} ? " disabled='disabled'" : ""; + my $ehtml = $opts->{noescape} ? 0 : 1; + my $value = $opts->{value} || ''; + $value = ehtml( $value ) if $ehtml; + + my $ret = "<textarea"; foreach (grep { ! /^(disabled|raw|value|noescape)$/ } keys %$opts) { $ret .= " $_=\"" . ($ehtml ? ehtml($opts->{$_}) : $opts->{$_}) . "\""; } - if ($opts->{'raw'}) { $ret .= " $opts->{'raw'}"; } - $ret .= "$disabled>" . ($ehtml ? ehtml($opts->{'value'}) : $opts->{'value'}) . "</textarea>"; + $ret .= " $opts->{raw}" if $opts->{raw}; + $ret .= "$disabled>$value</textarea>"; return $ret; } diff -r 296aacab97c2 -r a3640a29ac07 cgi-bin/weblib.pl --- a/cgi-bin/weblib.pl Sun Oct 03 18:01:08 2010 +0800 +++ b/cgi-bin/weblib.pl Sun Oct 03 19:03:09 2010 +0800 @@ -1329,8 +1329,8 @@ RTE foreach (sort { $moods->{$a}->{'name'} cmp $moods->{$b}->{'name'} } keys %$moods) { push @moodlist, ($_, $moods->{$_}->{'name'}); - if ($opts->{'prop_current_mood'} eq $moods->{$_}->{'name'} || - $opts->{'prop_current_moodid'} == $_) { + if ( $opts->{prop_current_mood} && $opts->{prop_current_mood} eq $moods->{$_}->{name} || + $opts->{prop_current_moodid} && $opts->{prop_current_moodid} == $_ ) { $sel = $_; } } @@ -1583,7 +1583,7 @@ MOODS } ### Other Posting Options - $out .= LJ::Hooks::run_hook('add_extra_entryform_fields', { opts => $opts, tabindex => $tabindex }); + $out .= LJ::Hooks::run_hook( 'add_extra_entryform_fields', { opts => $opts, tabindex => $tabindex } ) || ''; $out .= "<span class='inputgroup-right'>"; # extra submit button so make sure it posts the form when person presses enter key @@ -1750,7 +1750,7 @@ PREVIEW # if custom security groups available, show them in a hideable div if ( scalar @trust_groups ) { - my $display = $opts->{'security'} eq "custom" ? "block" : "none"; + my $display = $opts->{security} && $opts->{security} eq "custom" ? "block" : "none"; $out .= LJ::help_icon("security", "<span id='security-help'>\n", "\n</span>\n"); $out .= "<div id='custom_boxes' class='pkg' style='display: $display;'>\n"; $out .= "<ul id='custom_boxes_list'>"; @@ -1759,7 +1759,7 @@ PREVIEW $out .= "<li>"; $out .= LJ::html_check({ 'name' => "custom_bit_$fg", 'id' => "custom_bit_$fg", - 'selected' => $opts->{"custom_bit_$fg"} || $opts->{'security_mask'}+0 & 1 << $fg }) . " "; + 'selected' => $opts->{"custom_bit_$fg"} || ( $opts->{security_mask} ? $opts->{security_mask} + 0 : 0 ) & 1 << $fg }) . " "; $out .= "<label for='custom_bit_$fg'>" . LJ::ehtml( $group->{groupname} ) . "</label>\n"; $out .= "</li>"; } diff -r 296aacab97c2 -r a3640a29ac07 htdocs/tools/endpoints/ctxpopup.bml --- a/htdocs/tools/endpoints/ctxpopup.bml Sun Oct 03 18:01:08 2010 +0800 +++ b/htdocs/tools/endpoints/ctxpopup.bml Sun Oct 03 19:03:09 2010 +0800 @@ -138,7 +138,7 @@ _c?> sleep(1.5) if $LJ::IS_DEV_SERVER; my %extrainfo = LJ::Hooks::run_hook("ctxpopup_extra_info", $u); - %ret = (%ret, %extrainfo); + %ret = (%ret, %extrainfo) if %extrainfo; $ret{is_banned} = $remote->has_banned( $u ) ? 1 : 0 if $remote; --------------------------------------------------------------------------------