]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 282748: uninitialized value in localtime in Format.pm
authormkanat%kerio.com <>
Fri, 25 Feb 2005 11:28:01 +0000 (11:28 +0000)
committermkanat%kerio.com <>
Fri, 25 Feb 2005 11:28:01 +0000 (11:28 +0000)
Patch By Frederic Buclin <LpSolit@gmail.com> r=wurblzap, a=myk

Bugzilla/BugMail.pm
Bugzilla/Util.pm
CGI.pl
process_bug.cgi

index df734ef6f4fb32d31e8e74dac23f17303f52bbd7..b4b0c9dfe2ef25b7c42b0b8dce7493e492133911 100644 (file)
@@ -201,7 +201,9 @@ sub ProcessOneBug($) {
     }
     $values{'estimated_time'} = format_time_decimal($values{'estimated_time'});
 
-    $values{'deadline'} = time2str("%Y-%m-%d", str2time($values{'deadline'}));
+    if ($values{'deadline'}) {
+        $values{'deadline'} = time2str("%Y-%m-%d", str2time($values{'deadline'}));
+    }
 
     my @dependslist;
     SendSQL("SELECT dependson FROM dependencies WHERE 
@@ -262,10 +264,6 @@ sub ProcessOneBug($) {
                      WHERE attach_id = $attachid");
             $diffpart->{'isprivate'} = FetchOneColumn();
         }
-        if( $fieldname eq 'deadline' ) {
-            $old = time2str("%Y-%m-%d", str2time($old));
-            $new = time2str("%Y-%m-%d", str2time($new));
-        }  
         $difftext = FormatTriple($what, $old, $new);
         $diffpart->{'header'} = $diffheader;
         $diffpart->{'fieldname'} = $fieldname;
index 3bc39ff09dea5932784fc7ab5d0f9151f39d1da6..7481c18c3bcdaabc0a2503dc6401878abea0e5ad 100644 (file)
@@ -277,14 +277,17 @@ sub file_mod_time ($) {
 
 sub ValidateDate {
     my ($date, $format) = @_;
+    my $date2;
 
-    my $ts  = str2time($date);
-    my $date2 = time2str("%Y-%m-%d", $ts);
+    # $ts is undefined if the parser fails.
+    my $ts = str2time($date);
+    if ($ts) {
+        $date2 = time2str("%Y-%m-%d", $ts);
 
-    $date =~ s/(\d+)-0*(\d+?)-0*(\d+?)/$1-$2-$3/; 
-    $date2 =~ s/(\d+)-0*(\d+?)-0*(\d+?)/$1-$2-$3/;
-
-    if ($date ne $date2) {
+        $date =~ s/(\d+)-0*(\d+?)-0*(\d+?)/$1-$2-$3/; 
+        $date2 =~ s/(\d+)-0*(\d+?)-0*(\d+?)/$1-$2-$3/;
+    }
+    if (!$ts || $date ne $date2) {
         ThrowUserError('illegal_date', {date => $date, format => $format});
     } 
 }
diff --git a/CGI.pl b/CGI.pl
index 1b556bc71bafe7b3afb276b2e6edf4e491252db0..ff2db2febb44b594058253da8701963d8738a951 100644 (file)
--- a/CGI.pl
+++ b/CGI.pl
@@ -396,11 +396,6 @@ sub GetBugActivity {
                 $changes = [];
             }  
             
-            if ($fieldname eq 'deadline') {
-                $removed = time2str("%Y-%m-%d", str2time($removed));
-                $added = time2str("%Y-%m-%d", str2time($added));
-            }
-        
             $operation->{'who'} = $who;
             $operation->{'when'} = $when;            
         
index c1f3c33bb95fbb366446278ce9a5f069654a0a93..3eccfa3707e2b352569223d5dde2e9f2a66dfbc2 100755 (executable)
@@ -1767,7 +1767,17 @@ foreach my $id (@idlist) {
             {
                 $check_dep_bugs = 1;
             }
-            
+
+            # Convert deadlines to the YYYY-MM-DD format. We use an
+            # intermediate $xxxtime to prevent errors in the web
+            # server log file when str2time($xxx) is undefined.
+            if ($col eq 'deadline') {
+                my $oldtime = str2time($old);
+                $old = ($oldtime) ? time2str("%Y-%m-%d", $oldtime) : '';
+                my $newtime = str2time($new);
+                $new = ($newtime) ? time2str("%Y-%m-%d", $newtime) : '';
+            }
+
             LogActivityEntry($id,$col,$old,$new,$whoid,$timestamp);
             $bug_changed = 1;
         }