]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 282737: Software Error from time-tracking fields during Change Columns
authormozilla%colinogilvie.co.uk <>
Wed, 20 Jul 2005 05:41:04 +0000 (05:41 +0000)
committermozilla%colinogilvie.co.uk <>
Wed, 20 Jul 2005 05:41:04 +0000 (05:41 +0000)
Patch by Joel, Me, r=wurblzap, a=myk

Bugzilla/Search.pm
buglist.cgi

index d00921c3a47064610ad5c9a3321cb4f5a231c0c8..3f88191761a07c6c9ee9dc1a8e76089246750140 100644 (file)
@@ -101,7 +101,12 @@ sub init {
         push @supptables, "components AS map_components";
         push @wherepart, "bugs.component_id = map_components.id";
     }
-
+    
+    if (grep($_ =~ /AS (actual_time|percentage_complete)$/, @$fieldsref)) {
+        push(@supptables, "longdescs AS ldtime");
+        push(@wherepart, "ldtime.bug_id = bugs.bug_id");
+    }
+    
     my $minvotes;
     if (defined $params->param('votes')) {
         my $c = trim($params->param('votes'));
@@ -171,11 +176,6 @@ sub init {
         push(@specialchart, ["keywords", $t, $params->param('keywords')]);
     }
 
-    if (lsearch($fieldsref, "(SUM(ldtime.work_time)*COUNT(DISTINCT ldtime.bug_when)/COUNT(bugs.bug_id)) AS actual_time") != -1) {
-        push(@supptables, "longdescs AS ldtime");
-        push(@wherepart, "ldtime.bug_id = bugs.bug_id");
-    }
-
     foreach my $id ("1", "2") {
         if (!defined ($params->param("email$id"))) {
             next;
index d42ba67af4d37b5e7550dae6c6e16f029320a597..e9408f23bc3ddf3b9c8d4d910cb348c21e9b900f 100755 (executable)
@@ -680,7 +680,15 @@ foreach my $fragment (split(/,/, $order)) {
         # Add order columns to selectnames
         # The fragment has already been validated
         $fragment =~ s/\s+(asc|desc)$//;
-        $fragment =~ tr/a-zA-Z\.0-9\-_//cd;
+        # This fixes an issue where columns being used in the ORDER BY statement
+        # can have the SQL that generates the value changed to become invalid -
+        # mainly affects time tracking.
+        if ($fragment =~ / AS (\w+)/) {
+            $fragment = $columns->{$1}->{'name'};
+        }
+        else {
+            $fragment =~ tr/a-zA-Z\.0-9\-_//cd;
+        }
         push @selectnames, $fragment;
     }
 }