]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Branch fix for bug 253604 When commit a bug, errors in the validation
authorkiko%async.com.br <>
Fri, 6 Aug 2004 05:19:21 +0000 (05:19 +0000)
committerkiko%async.com.br <>
Fri, 6 Aug 2004 05:19:21 +0000 (05:19 +0000)
must appear before user match. Moves time validation to the validation
section in process_bug.cgi. Backported Bugzilla::Bug::ValidateTime to
get this to work on branch.  Patch by Tiago R. Mello
<tiago@async.com.br>, r=joel, vladd; a218=justdave.

Bugzilla/Bug.pm
process_bug.cgi

index 20c131e2271aa41416b74fb07e1b186810db141d..919c726de4c1d8c5290356a0bd2af44b7b7b3e0a 100755 (executable)
@@ -491,6 +491,13 @@ sub EmitDependList {
   return @list;
 }
 
+sub ValidateTime {
+  my ($time, $field) = @_;
+  if ($time > 99999.99 || $time < 0 || !($time =~ /^(?:\d+(?:\.\d*)?|\.\d+)$/)) {
+    &::ThrowUserError("need_positive_number", {field => "$field"}, "abort");
+  }
+}
+
 sub AUTOLOAD {
   use vars qw($AUTOLOAD);
   my $attr = $AUTOLOAD;
index d759aa8dbd731fd50bdaf78e4eb870fd17f6324a..5869a0363d67168babac577fb8da5fb41e824b26 100755 (executable)
@@ -91,6 +91,16 @@ if (defined $::FORM{'id'}) {
 # Make sure there are bugs to process.
 scalar(@idlist) || ThrowUserError("no_bugs_chosen");
 
+# Validate all timetracking fields
+foreach my $field ("estimated_time", "work_time", "remaining_time") {
+    if (defined $::FORM{$field}) {
+        my $er_time = trim($::FORM{$field});
+        if ($er_time ne $::FORM{'dontchange'}) {
+            Bugzilla::Bug::ValidateTime($er_time, $field);
+        }
+    }
+}
+
 # do a match on the fields if applicable
 
 # The order of these function calls is important, as both Flag::validate
@@ -773,16 +783,8 @@ if (UserInGroup(Param('timetrackinggroup'))) {
         if (defined $::FORM{$field}) {
             my $er_time = trim($::FORM{$field});
             if ($er_time ne $::FORM{'dontchange'}) {
-                if ($er_time > 99999.99) {
-                    ThrowUserError("value_out_of_range", {field => $field});
-                }
-                if ($er_time =~ /^(?:\d+(?:\.\d*)?|\.\d+)$/) {
-                    DoComma();
-                    $::query .= "$field = " . SqlQuote($er_time);
-                } else {
-                    ThrowUserError("need_positive_number",
-                                   {field => $field});
-                }
+                DoComma();
+                $::query .= "$field = " . SqlQuote($er_time);
             }
         }
     }
@@ -1282,9 +1284,6 @@ foreach my $id (@idlist) {
 
     delete $::FORM{'work_time'} unless UserInGroup(Param('timetrackinggroup'));
 
-    if ($::FORM{'work_time'} && $::FORM{'work_time'} > 99999.99) {
-        ThrowUserError("value_out_of_range", {field => 'work_time'});
-    }
     if ($::FORM{'comment'} || $::FORM{'work_time'}) {
         if ($::FORM{'work_time'} && 
             (!defined $::FORM{'comment'} || $::FORM{'comment'} =~ /^\s*$/)) {