fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-12-28 01:05 pm

[dw-free] hush warnings in DayPage.pm

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

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

Check for definedness, before trying to manipulate. In the second section,
the s/// modifies the $prev/$next variables, so we can do it a simpler way.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/LJ/S2/DayPage.pm
--------------------------------------------------------------------------------
diff -r 7474d8f1cc7e -r 5c788c49952f cgi-bin/LJ/S2/DayPage.pm
--- a/cgi-bin/LJ/S2/DayPage.pm	Tue Dec 28 20:58:23 2010 +0800
+++ b/cgi-bin/LJ/S2/DayPage.pm	Tue Dec 28 21:05:03 2010 +0800
@@ -152,10 +152,12 @@ sub DayPage
     }
 
     # create Date objects for ($prev, $next) pair
-    my ($pdate, $ndate) = map { /^(\d\d\d\d)(\d\d)(\d\d)\b/ ? Date($1, $2, $3) : Null('Date') } ($prev, $next);
+    my ( $pdate, $ndate ) = map { defined $_ && /^(\d\d\d\d)(\d\d)(\d\d)\b/
+                                ? Date( $1, $2, $3 ) : Null( 'Date' ) }
+                            ( $prev, $next );
 
     # insert slashes into $prev and $next
-    ($prev, $next)      = map { s!^(\d\d\d\d)(\d\d)(\d\d)\b!$1/$2/$3!; $_ } ($prev, $next);
+    map { defined $_ && s!^(\d\d\d\d)(\d\d)(\d\d)\b!$1/$2/$3! } ( $prev, $next );
 
     $p->{'prev_url'} = defined $prev ? ("$u->{'_journalbase'}/$prev") : '';
     $p->{'prev_date'} = $pdate;
--------------------------------------------------------------------------------