[dw-free] clean up log messages that appear when global warnings are on
[commit: http://hg.dwscoalition.org/dw-free/rev/eb0491af909b]
http://bugs.dwscoalition.org/show_bug.cgi?id=3040
More cleanup of variables (initializing, making sure we don't declare twice
in the same scope)
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3040
More cleanup of variables (initializing, making sure we don't declare twice
in the same scope)
Patch by
Files modified:
- cgi-bin/DW/Widget/CommunityManagement.pm
- cgi-bin/LJ/Comment.pm
- cgi-bin/LJ/S2/FriendsPage.pm
- cgi-bin/LJ/Talk.pm
- cgi-bin/LJ/Widget/CurrentTheme.pm
- cgi-bin/LJ/Widget/MoodThemeChooser.pm
- cgi-bin/LJ/Widget/S2PropGroup.pm
- cgi-bin/weblib.pl
- htdocs/tools/endpoints/ctxpopup.bml
- htdocs/tools/recent_comments.bml
- htdocs/update.bml
--------------------------------------------------------------------------------
diff -r 439ad38d4bd7 -r eb0491af909b cgi-bin/DW/Widget/CommunityManagement.pm
--- a/cgi-bin/DW/Widget/CommunityManagement.pm Fri Oct 15 19:19:05 2010 +0800
+++ b/cgi-bin/DW/Widget/CommunityManagement.pm Sat Oct 16 22:14:28 2010 +0800
@@ -62,7 +62,7 @@ sub render_body {
my $pending_members_count;
$pending_members_count = $cu->get_pending_members_count
- if $membership eq "moderated" && $admin{$cu->userid};
+ if $membership && $membership eq "moderated" && $admin{$cu->userid};
if ( $pending_members_count || $pending_entries_count ) {
$list .= "<dt>" . $cu->ljuser_display;
$list .= "<dd>" . $class->ml( 'widget.communitymanagement.pending' );
diff -r 439ad38d4bd7 -r eb0491af909b cgi-bin/LJ/Comment.pm
--- a/cgi-bin/LJ/Comment.pm Fri Oct 15 19:19:05 2010 +0800
+++ b/cgi-bin/LJ/Comment.pm Sat Oct 16 22:14:28 2010 +0800
@@ -880,7 +880,7 @@ sub state {
sub state {
my $self = $_[0];
__PACKAGE__->preload_rows([ $self->unloaded_singletons] );
- return $self->{state};
+ return $self->{state} || '';
}
diff -r 439ad38d4bd7 -r eb0491af909b cgi-bin/LJ/S2/FriendsPage.pm
--- a/cgi-bin/LJ/S2/FriendsPage.pm Fri Oct 15 19:19:05 2010 +0800
+++ b/cgi-bin/LJ/S2/FriendsPage.pm Sat Oct 16 22:14:28 2010 +0800
@@ -87,7 +87,7 @@ sub FriendsPage
# load options for image links
my ($maximgwidth, $maximgheight) = (undef, undef);
($maximgwidth, $maximgheight) = ($1, $2)
- if ( $remote && $remote->equals( $u ) &&
+ if ( $remote && $remote->equals( $u ) && $remote->{opt_imagelinks} &&
$remote->{opt_imagelinks} =~ m/^(\d+)\|(\d+)$/ );
## never have spiders index friends pages (change too much, and some
@@ -98,13 +98,14 @@ sub FriendsPage
if ($itemshow < 1) { $itemshow = 20; }
elsif ($itemshow > 50) { $itemshow = 50; }
- my $skip = $get->{'skip'}+0;
+ my $skip = $get->{skip} ? $get->{skip} + 0 : 0;
my $maxskip = ($LJ::MAX_SCROLLBACK_FRIENDS || 1000) - $itemshow;
if ($skip > $maxskip) { $skip = $maxskip; }
if ($skip < 0) { $skip = 0; }
my $itemload = $itemshow+$skip;
+ my $get_date = $get->{date} || '';
- my $events_date = ($get->{date} =~ m!^(\d{4})-(\d\d)-(\d\d)$!)
+ my $events_date = ( $get_date =~ m!^(\d{4})-(\d\d)-(\d\d)$! )
? LJ::mysqldate_to_time("$1-$2-$3")
: 0;
@@ -131,7 +132,7 @@ sub FriendsPage
$p->{filter_name} = $opts->{securityfilter};
} else {
# but we can't just use a filter, we have to make sure the person is allowed to
- if ( ( $get->{filter} ne "0" ) && $cf && ( $u->equals( $remote ) || $cf->public ) ) {
+ if ( $get->{filter} && $get->{filter} ne "0" && $cf && ( $u->equals( $remote ) || $cf->public ) ) {
$filter = $cf;
# if we couldn't use the group, then we can throw an error, but ONLY IF they specified
diff -r 439ad38d4bd7 -r eb0491af909b cgi-bin/LJ/Talk.pm
--- a/cgi-bin/LJ/Talk.pm Fri Oct 15 19:19:05 2010 +0800
+++ b/cgi-bin/LJ/Talk.pm Sat Oct 16 22:14:28 2010 +0800
@@ -364,13 +364,13 @@ sub screening_level {
LJ::load_log_props2($journalu->{userid}, [ $jitemid ], \%props);
# determine if userprop was overriden
- my $val = $props{$jitemid}{opt_screening};
+ my $val = $props{$jitemid}{opt_screening} || '';
return if $val eq 'N'; # N means None, so return undef
return $val if $val;
# now return userprop, as it's our last chance
my $userprop = $journalu->prop( 'opt_whoscreened' );
- return $userprop eq 'N' ? undef : $userprop;
+ return $userprop && $userprop eq 'N' ? undef : $userprop;
}
sub update_commentalter {
@@ -1392,14 +1392,17 @@ sub talkform {
$form->{'userpost'} eq $form->{'cookieuser'});
# Possible remote, using ljuser field
- if ($type eq 'ljuser') {
- return $default if
+ if ( $type eq 'ljuser' ) {
+ my $cookieuser = $form->{cookieuser} || '';
# Remote user posting as someone else.
- ($form->{'userpost'} && $form->{'userpost'} ne $form->{'cookieuser'} && $form->{'usertype'} ne 'anonymous') ||
- ($form->{'usertype'} eq 'user' && ! $form->{'userpost'});
- }
-
- return;
+ return $default if $form->{userpost} &&
+ $form->{userpost} ne $cookieuser &&
+ $form->{usertype} ne 'anonymous';
+ return $default if ! $form->{userpost} && $form->{usertype} &&
+ $form->{usertype} eq 'user';
+ }
+
+ return '';
};
my $bantext = sub {
@@ -1420,7 +1423,7 @@ sub talkform {
# special link to create an account
my $create_link;
if (!$remote || defined $oid_identity) {
- $create_link = LJ::Hooks::run_hook("override_create_link_on_talkpost_form", $journalu);
+ $create_link = LJ::Hooks::run_hook( "override_create_link_on_talkpost_form", $journalu ) || '';
$ret .= $create_link;
}
@@ -1429,7 +1432,7 @@ sub talkform {
$ret .= "<tr><td align='right' valign='top'>$BML::ML{'.opt.from'}</td>";
$ret .= "<td>";
$ret .= "<table>"; # Internal for "From" options
- my $screening = LJ::Talk::screening_level($journalu, $opts->{ditemid} >> 8);
+ my $screening = LJ::Talk::screening_level( $journalu, $opts->{ditemid} >> 8 ) || '';
if ($editid) {
@@ -1893,11 +1896,11 @@ sub talkform {
# textarea for their message body
$ret .= "<tr valign='top'><td align='right'>$BML::ML{'.opt.message'}";
$ret .= "</td><td style='width: 90%'>";
- $ret .= "<textarea class='textbox' rows='10' cols='75' wrap='soft' name='body' id='commenttext'>" . LJ::ehtml($form->{body}) . "</textarea><br />";
+ $ret .= "<textarea class='textbox' rows='10' cols='75' wrap='soft' name='body' id='commenttext'>" . LJ::ehtml( $form->{body} || '' ) . "</textarea><br />";
# if parent comment is screened, and user can unscreen, give option to unscreen it
# default is not to unscreen
- if ( $parpost->{state} eq "S" && LJ::Talk::can_unscreen( $remote, $journalu, $entry->poster ) ) {
+ if ( $parpost->is_screened && LJ::Talk::can_unscreen( $remote, $journalu, $entry->poster ) ) {
$ret .= "<label for='unscreen_parent'>$BML::ML{'.opt.unscreenparent'}</label>";
$ret .= LJ::html_check(
{
diff -r 439ad38d4bd7 -r eb0491af909b cgi-bin/LJ/Widget/CurrentTheme.pm
--- a/cgi-bin/LJ/Widget/CurrentTheme.pm Fri Oct 15 19:19:05 2010 +0800
+++ b/cgi-bin/LJ/Widget/CurrentTheme.pm Sat Oct 16 22:14:28 2010 +0800
@@ -25,6 +25,7 @@ sub render_body {
sub render_body {
my $class = shift;
my %opts = @_;
+ $opts{show} ||= 0;
my $u = $class->get_effective_remote();
die "Invalid user." unless LJ::isu($u);
diff -r 439ad38d4bd7 -r eb0491af909b cgi-bin/LJ/Widget/MoodThemeChooser.pm
--- a/cgi-bin/LJ/Widget/MoodThemeChooser.pm Fri Oct 15 19:19:05 2010 +0800
+++ b/cgi-bin/LJ/Widget/MoodThemeChooser.pm Sat Oct 16 22:14:28 2010 +0800
@@ -64,7 +64,7 @@ sub render_body {
$ret .= "</ul>";
$ret .= "</div>";
- my $moodtheme_extra = LJ::Hooks::run_hook("mood_theme_extra_content", $u, \@themes);
+ my $moodtheme_extra = LJ::Hooks::run_hook( "mood_theme_extra_content", $u, \@themes ) || '';
my $show_special = $moodtheme_extra ? "special" : "nospecial";
my $mobj = DW::Mood->new( $preview_moodthemeid );
diff -r 439ad38d4bd7 -r eb0491af909b cgi-bin/LJ/Widget/S2PropGroup.pm
--- a/cgi-bin/LJ/Widget/S2PropGroup.pm Fri Oct 15 19:19:05 2010 +0800
+++ b/cgi-bin/LJ/Widget/S2PropGroup.pm Sat Oct 16 22:14:28 2010 +0800
@@ -363,7 +363,7 @@ sub output_prop_element {
my $existing = $prop_values{existing};
my $override = $prop_values{override};
- my %values = split(/\|/, $prop->{values});
+ my %values = split( /\|/, $prop->{values} || '' );
my $existing_display = defined $values{$existing} ? $values{$existing} : $existing;
$existing_display = LJ::eall($existing_display);
@@ -453,9 +453,9 @@ sub output_prop_element {
$ret .= "</td>" unless $is_group;
} elsif ($type eq "string") {
- my ($rows, $cols, $full) = ($prop->{rows}+0,
- $prop->{cols}+0,
- $prop->{full}+0);
+ my $rows = $prop->{rows} ? $prop->{rows} + 0 : 0;
+ my $cols = $prop->{cols} ? $prop->{cols} + 0 : 0;
+ my $full = $prop->{full} ? $prop->{full} + 0 : 0;
$ret .= "<td class='prop-input'>" unless $is_group;
if ($full > 0) {
diff -r 439ad38d4bd7 -r eb0491af909b cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl Fri Oct 15 19:19:05 2010 +0800
+++ b/cgi-bin/weblib.pl Sat Oct 16 22:14:28 2010 +0800
@@ -53,7 +53,7 @@ sub img
my $type = shift; # either "" or "input"
my $attr = shift;
- my ( $attrs, $alt, $ssl );
+ my ( $attrs, $alt, $ssl ) = ( '', '' );
if ( $attr ) {
if ( ref $attr eq "HASH" ) {
if ( exists $attr->{alt} ) {
@@ -191,8 +191,8 @@ sub make_authas_select {
my $button = $opts->{button} || $BML::ML{'web.authas.btn'};
my $label = $opts->{label};
- $label ||= $opts->{type} eq "C" ? $BML::ML{'web.authas.label.comm'}
- : $BML::ML{'web.authas.label'};
+ my $comm = $opts->{type} && $opts->{type} eq "C" ? ".comm" : "";
+ $label ||= $BML::ML{"web.authas.label$comm"};
my @list = $u->get_authas_list( $opts );
@@ -1949,7 +1949,7 @@ sub entry_form_usericon_widget {
my $remote = shift;
return undef unless LJ::isu( $remote );
- my $ret;
+ my $ret = '';
my %res;
LJ::do_request({ mode => "login",
@@ -1980,7 +1980,7 @@ sub entry_form_xpost_widget {
my ( $remote ) = @_;
return unless $remote;
- my $ret;
+ my $ret = '';
my @accounts = DW::External::Account->get_external_accounts( $remote );
@accounts = grep { $_->xpostbydefault } @accounts;
@@ -2616,17 +2616,14 @@ sub control_strip
}
my $selected = "all";
- if ($r->uri eq "/read" && $r->query_string ne "") {
+ if ( ( $r->uri eq "/read" || $r->uri eq "/network" ) &&
+ $r->query_string && $r->query_string ne "" ) {
$selected = "showpeople" if $r->query_string =~ /\bshow=P\b/;
$selected = "showcommunities" if $r->query_string =~ /\bshow=C\b/;
$selected = "showsyndicated" if $r->query_string =~ /\bshow=F\b/;
} elsif ($r->uri =~ /^\/read\/?(.+)?/i) {
my $filter = $1 || "default view";
$selected = "filter:" . LJ::durl( lc( $filter ) );
- } elsif ($r->uri eq "/network" && $r->query_string ne "") {
- $selected = "showpeople" if $r->query_string =~ /\bshow=P\b/;
- $selected = "showcommunities" if $r->query_string =~ /\bshow=C\b/;
- $selected = "showsyndicated" if $r->query_string =~ /\bshow=F\b/;
}
$ret .= "$links{'manage_friends'} ";
@@ -2827,7 +2824,7 @@ LOGIN_BAR
$ret .= "<br />";
$ret .= "$links{'login'} " unless $show_login_form;
$ret .= "$links{'create_account'} $links{'learn_more'}";
- $ret .= LJ::Hooks::run_hook('control_strip_logo', $remote, $journal);
+ $ret .= LJ::Hooks::run_hook( 'control_strip_logo', $remote, $journal ) || '';
$ret .= "</td>";
}
diff -r 439ad38d4bd7 -r eb0491af909b htdocs/tools/endpoints/ctxpopup.bml
--- a/htdocs/tools/endpoints/ctxpopup.bml Fri Oct 15 19:19:05 2010 +0800
+++ b/htdocs/tools/endpoints/ctxpopup.bml Sat Oct 16 22:14:28 2010 +0800
@@ -137,7 +137,7 @@ _c?>
}
sleep(1.5) if $LJ::IS_DEV_SERVER;
- my %extrainfo = LJ::Hooks::run_hook("ctxpopup_extra_info", $u);
+ my %extrainfo = LJ::Hooks::run_hook( "ctxpopup_extra_info", $u ) || ();
%ret = (%ret, %extrainfo) if %extrainfo;
$ret{is_banned} = $remote->has_banned( $u ) ? 1 : 0 if $remote;
diff -r 439ad38d4bd7 -r eb0491af909b htdocs/tools/recent_comments.bml
--- a/htdocs/tools/recent_comments.bml Fri Oct 15 19:19:05 2010 +0800
+++ b/htdocs/tools/recent_comments.bml Sat Oct 16 22:14:28 2010 +0800
@@ -119,7 +119,6 @@ body<=
unless grep { $count == $_ } @values;
push @values, $max
unless grep { $max == $_ } @values;
- my $getextra = $u->equals( $remote ) ? "" : "&authas=" . $u->user;
@values = sort { $a <=> $b } @values;
@@ -203,25 +202,25 @@ body<=
unless ($r->{state} eq "D") {
$ret .= "<a href='/delcomment?${jargent}id=$talkid'>";
- $ret .= LJ::img("btn_del", "", { 'align' => 'absmiddle', 'hspace' => 2, 'vspace' => }) . "</a>";
+ $ret .= LJ::img( "btn_del", "", { align => 'absmiddle', hspace => 2 } ) . "</a>";
if ($r->{'state'} ne 'F') {
$ret .= "<a href='/talkscreen?mode=freeze&${jargent}talkid=$talkid'>";
- $ret .= LJ::img("btn_freeze", "", { align => 'absmiddle', hspace => 2, vspace => }) . "</a>";
+ $ret .= LJ::img( "btn_freeze", "", { align => 'absmiddle', hspace => 2 } ) . "</a>";
}
if ($r->{'state'} eq 'F') {
$ret .= "<a href='/talkscreen?mode=unfreeze&${jargent}talkid=$talkid'>";
- $ret .= LJ::img("btn_unfreeze", "", { align => 'absmiddle', hspace => 2, vspace => }) . "</a>";
+ $ret .= LJ::img( "btn_unfreeze", "", { align => 'absmiddle', hspace => 2 } ) . "</a>";
}
if ($r->{'state'} ne 'S') {
$ret .= "<a href='/talkscreen?mode=screen&${jargent}talkid=$talkid'>";
- $ret .= LJ::img("btn_scr", "", { 'align' => 'absmiddle', 'hspace' => 2, 'vspace' => }) . "</a>";
+ $ret .= LJ::img( "btn_scr", "", { align => 'absmiddle', hspace => 2 } ) . "</a>";
}
if ($r->{'state'} eq 'S') {
$ret .= "<a href='/talkscreen?mode=unscreen&${jargent}talkid=$talkid'>";
- $ret .= LJ::img("btn_unscr", "", { 'align' => 'absmiddle', 'hspace' => 2, 'vspace' => }) . "</a>";
+ $ret .= LJ::img( "btn_unscr", "", { align => 'absmiddle', hspace => 2 } ) . "</a>";
}
}
@@ -232,16 +231,16 @@ body<=
$ret .= "</td><td id='" . LJ::Talk::comment_htmlid( $talkid );
$ret .= "' style='text-align: left; border-top: 1px solid #999; border-left: 1px solid #999'>";
- my $subject = $log_text->{"$u->{userid}:$r->{nodeid}"}[0];
- LJ::CleanHTML::clean_subject(\$subject) if $subject ne "";
+ my $esubject = $log_text->{"$u->{userid}:$r->{nodeid}"}[0];
+ LJ::CleanHTML::clean_subject(\$esubject) if $esubject ne "";
- $ret .= "<strong style='float: left; text-decoration: underline'>$subject</strong> " if $subject ne "";
+ $ret .= "<strong style='float: left; text-decoration: underline'>$esubject</strong> " if $esubject ne "";
$ret .= "<strong style='float: right'>(<a href='$ditemid'>$ML{ '.entry.link' }</a>)</strong>" unless $lrow->{ditemid} == undef;
$ret .= "<br /><br />";
- my $subject = LJ::ehtml($comment_text->{$r->{jtalkid}}[0]);
+ my $csubject = LJ::ehtml($comment_text->{$r->{jtalkid}}[0]);
- if ($subject && $subject !~ /^Re:\s*$/) {
- $ret .= "<cite>$subject</cite><br />";
+ if ($csubject && $csubject !~ /^Re:\s*$/) {
+ $ret .= "<cite>$csubject</cite><br />";
}
my $comment = $comment_text->{$r->{jtalkid}}[1];
diff -r 439ad38d4bd7 -r eb0491af909b htdocs/update.bml
--- a/htdocs/update.bml Fri Oct 15 19:19:05 2010 +0800
+++ b/htdocs/update.bml Sat Oct 16 22:14:28 2010 +0800
@@ -553,7 +553,7 @@ head<=
# name.
$draft = LJ::ejs_string($remote->prop('entry_draft'));
%draft_properties = $remote->prop( 'draft_properties' ) ?
- %{Storable::thaw( $remote->prop( 'draft_properties' ) )} : ' ';
+ %{ Storable::thaw( $remote->prop( 'draft_properties' ) ) } : ();
# store raw for later use; will be escaped later
$draft_subject_raw = $draft_properties{subject};
--------------------------------------------------------------------------------
