Skip to content

Commit 52ed843

Browse files
authored
fix some issues with converted /manage/profile page (#3441)
* fix bday month * fix undefined value warnings Use of uninitialized value in numeric ge (>=) ... cgi-bin/DW/Controller/Manage/Profile.pm line 258. Use of uninitialized value $newbio in pattern match (m//) ... cgi-bin/DW/Controller/Manage/Profile.pm line 285. Use of uninitialized value in numeric gt (>) ... cgi-bin/DW/Controller/Manage/Profile.pm line 348. * pass $iscomm variable to page template This was missing from the $vars hash. * more undefined value warnings Use of uninitialized value in pattern match (m//) ... cgi-bin/DW/Controller/Manage/Profile.pm line 155. Use of uninitialized value in pattern match (m//) ... cgi-bin/DW/Controller/Manage/Profile.pm line 172. * start birthday month menu with empty value
1 parent f722918 commit 52ed843

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

cgi-bin/DW/Controller/Manage/Profile.pm

+15-6
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,11 @@ sub profile_handler {
151151
if ( $bdpart{'day'} eq "00" ) { $bdpart{'day'} = ""; }
152152
}
153153

154-
my @months = map { $_, LJ::Lang::month_long_ml($_) } ( 1 .. 12 );
155-
$u->{'opt_showbday'} = "D" unless $u->{'opt_showbday'} =~ m/^(D|F|N|Y)$/;
154+
my @months = ( 0, "" );
155+
push @months, map { $_, LJ::Lang::month_long_ml($_) } ( 1 .. 12 );
156+
157+
$u->{'opt_showbday'} = "D"
158+
unless defined $u->{'opt_showbday'} and $u->{'opt_showbday'} =~ m/^(D|F|N|Y)$/;
156159
my $opt_sharebday = ( $u->opt_sharebday =~ m/^(A|F|N|R)$/ ) ? $u->opt_sharebday : 'F';
157160

158161
# 'Other Services' display
@@ -169,7 +172,7 @@ sub profile_handler {
169172
# Email display
170173
# This is one prop in the backend, but two form fields on the settings page
171174
# so we need to do some jumping around to get the correct values for both fields
172-
my $checked = ( $u->{'opt_whatemailshow'} =~ /[BVL]/ ) ? 'Y' : 'N';
175+
my $checked = ( ( $u->{'opt_whatemailshow'} // '' ) =~ /[BVL]/ ) ? 'Y' : 'N';
173176
my $cur = $u->opt_whatemailshow;
174177

175178
# drop BVL values that govern site alias; we input that below instead
@@ -179,6 +182,7 @@ sub profile_handler {
179182
u => $u,
180183
authas_html => $rv->{authas_html},
181184
formdata => $POST,
185+
iscomm => $iscomm,
182186
curr_privacy => $curr_privacy,
183187
opt_sharebday => $opt_sharebday,
184188
text_in => \&LJ::text_in,
@@ -255,7 +259,7 @@ sub profile_handler {
255259
}
256260

257261
# bio
258-
if ( length( $POST->{'bio'} ) >= LJ::BMAX_BIO ) {
262+
if ( defined $POST->{'bio'} and length( $POST->{'bio'} ) >= LJ::BMAX_BIO ) {
259263
$errors->add( 'bio', "$scope.error.bio.toolong" );
260264
}
261265

@@ -282,7 +286,8 @@ sub profile_handler {
282286
$newname = LJ::text_trim( $newname, LJ::BMAX_NAME, LJ::CMAX_NAME );
283287

284288
my $newbio = defined( $POST->{'bio_absent'} ) ? $saved{'bio'} : $POST->{'bio'};
285-
my $has_bio = ( $newbio =~ /\S/ ) ? "Y" : "N";
289+
$newbio = "" unless defined $newbio;
290+
my $has_bio = ( $newbio =~ /\S/ ) ? "Y" : "N";
286291
my $new_bdate = sprintf( "%04d-%02d-%02d",
287292
$POST->{'year'} || 0,
288293
$POST->{'month'} || 0,
@@ -344,7 +349,11 @@ sub profile_handler {
344349
if ( $POST->{'opt_sharebday'} =~ /^[AR]$/ ) {
345350

346351
# and actually provided a birthday
347-
if ( $POST->{'month'} && $POST->{'month'} > 0 && $POST->{'day'} > 0 ) {
352+
if ( $POST->{'month'}
353+
&& $POST->{'month'} > 0
354+
&& $POST->{'day'}
355+
&& $POST->{'day'} > 0 )
356+
{
348357

349358
# and allow the entire thing to be displayed
350359
if ( $POST->{'opt_showbday'} eq "F" && $POST->{'year'} ) {

views/manage/profile.tt

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<td class='field_name' role="cell">[% dw.ml('.fn.birthday') %]</td>
9999
<td class='bday_field' role="cell">
100100
[%- form.select( name => 'month', title => dw.ml('.fn.birthday.month'),
101-
selected => int( bdpart.month ),
101+
selected => ( bdpart.month + 0 ),
102102
items => month_select,
103103
class => 'inline'
104104
) -%]

0 commit comments

Comments
 (0)