]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 257315 : type of delta_ts in bugs table should not be timestamp
authortravis%sedsystems.ca <>
Wed, 9 Feb 2005 00:51:02 +0000 (00:51 +0000)
committertravis%sedsystems.ca <>
Wed, 9 Feb 2005 00:51:02 +0000 (00:51 +0000)
Patch by Tomas Kopal <Tomas.Kopal@altap.cz>  r=mkanat, LpSolit   a=justdave

16 files changed:
Bugzilla/BugMail.pm
CGI.pl
attachment.cgi
checksetup.pl
contrib/bug_email.pl
contrib/jb2bz.py
editmilestones.cgi
editproducts.cgi
editversions.cgi
globals.pl
importxml.pl
move.pl
post_bug.cgi
process_bug.cgi
sanitycheck.cgi
votes.cgi

index 77156b0e7d4c08b1bb63193eac7b5e0379273493..ab511176cdae14bb201c776c403962251e723a37 100644 (file)
@@ -423,8 +423,7 @@ sub ProcessOneBug($) {
     }
 
 
-    SendSQL("UPDATE bugs SET lastdiffed = '$end', delta_ts = delta_ts " .
-            "WHERE bug_id = $id");
+    SendSQL("UPDATE bugs SET lastdiffed = '$end' WHERE bug_id = $id");
 
     # Filter the exclude list for dupes one last time
     @excludedAddresses = filterExcludeList(\@excludedAddresses,
diff --git a/CGI.pl b/CGI.pl
index 58075bacbebb08b24b73b6a7e6e529f17531e2e1..1a8f09c2fa984223aa0c8f32e27cc2af0f536e1d 100644 (file)
--- a/CGI.pl
+++ b/CGI.pl
@@ -246,32 +246,34 @@ sub CheckIfVotedConfirmed {
     my ($id, $who) = (@_);
     PushGlobalSQLState();
     SendSQL("SELECT bugs.votes, bugs.bug_status, products.votestoconfirm, " .
-            "       bugs.everconfirmed " .
+            "       bugs.everconfirmed, NOW() " .
             "FROM bugs, products " .
             "WHERE bugs.bug_id = $id AND products.id = bugs.product_id");
-    my ($votes, $status, $votestoconfirm, $everconfirmed) = (FetchSQLData());
+    my ($votes, $status, $votestoconfirm, $everconfirmed, $timestamp) = (FetchSQLData());
+    my $sql_timestamp = SqlQuote($timestamp);
     my $ret = 0;
     if ($votes >= $votestoconfirm && $status eq 'UNCONFIRMED') {
-        SendSQL("UPDATE bugs SET bug_status = 'NEW', everconfirmed = 1 " .
-                "WHERE bug_id = $id");
+        SendSQL("UPDATE bugs SET bug_status = 'NEW', everconfirmed = 1, " .
+                "delta_ts = $sql_timestamp WHERE bug_id = $id");
         my $fieldid = GetFieldID("bug_status");
         SendSQL("INSERT INTO bugs_activity " .
-                "(bug_id,who,bug_when,fieldid,removed,added) VALUES " .
-                "($id,$who,now(),$fieldid,'UNCONFIRMED','NEW')");
+                "(bug_id, who, bug_when, fieldid, removed, added) VALUES " .
+                "($id, $who, $sql_timestamp, $fieldid, 'UNCONFIRMED', 'NEW')");
         if (!$everconfirmed) {
             $fieldid = GetFieldID("everconfirmed");
             SendSQL("INSERT INTO bugs_activity " .
-                    "(bug_id,who,bug_when,fieldid,removed,added) VALUES " .
-                    "($id,$who,now(),$fieldid,'0','1')");
+                    "(bug_id, who, bug_when, fieldid, removed, added) VALUES " .
+                    "($id, $who, $sql_timestamp, $fieldid, '0', '1')");
         }
-        
+
         AppendComment($id, DBID_to_name($who),
-                      "*** This bug has been confirmed by popular vote. ***", 0);
-                      
+                      "*** This bug has been confirmed by popular vote. ***",
+                      0, $timestamp);
+
         $vars->{'type'} = "votes";
         $vars->{'id'} = $id;
         $vars->{'mailrecipients'} = { 'changer' => $who };
-        
+
         $template->process("bug/process/results.html.tmpl", $vars)
           || ThrowTemplateError($template->error());
         $ret = 1;
index 202c8818f8a69b7ea09e70348e054634ad921c26..a5407e8b09d91ec14d21e7f967d70e9aa483d463 100755 (executable)
@@ -940,7 +940,7 @@ sub insert
       @newvalues = map(SqlQuote($_), @newvalues);
                
       # Update the bug record. Note that this doesn't involve login_name.
-      SendSQL("UPDATE bugs SET " . 
+      SendSQL("UPDATE bugs SET delta_ts = $sql_timestamp, " . 
               join(", ", map("$fields[$_] = $newvalues[$_]", (0..2))) . 
               " WHERE bug_id = $::FORM{'bugid'}");
       
index daabfa8f4b7d98576ed4af5730429b6e83da563b..409568b83153708a8a4a8e62ead09e37476c95f7 100755 (executable)
@@ -1767,7 +1767,7 @@ $table{bugs} =
     bug_severity enum($my_severities) not null,
     bug_status enum("UNCONFIRMED", "NEW", "ASSIGNED", "REOPENED", "RESOLVED", "VERIFIED", "CLOSED") not null,
     creation_ts datetime not null,
-    delta_ts timestamp not null,
+    delta_ts datetime not null,
     short_desc mediumtext not null,
     op_sys enum($my_opsys) not null,
     priority enum($my_priorities) not null,
@@ -4703,6 +4703,13 @@ if ($emptygroupid) {
     print "Group $emptygroupid had an empty name; renamed as '$trygroupname'.\n";
 }
 
+# 2005-01-17 - Tomas.Kopal@altap.cz, bug 257315
+# Change bugs.delta_ts type from timestamp to datetime
+if (($fielddef = GetFieldDef("bugs", "delta_ts")) &&
+    $fielddef->[1] =~ /^timestamp/) {
+    ChangeFieldType ('bugs', 'delta_ts', 'DATETIME NOT NULL');
+}
+
 #
 # Final checks...
 
index 6589401e89f83aaf16bf3be6023f4088733b0dae..1f2f28421152688f1fcac92481d6e9369b32b7a0 100755 (executable)
@@ -38,7 +38,7 @@
 #
 # You need to work with bug_email.pl the MIME::Parser installed.
 # 
-# $Id: bug_email.pl,v 1.22 2005/01/30 04:22:28 justdave%bugzilla.org Exp $
+# $Id: bug_email.pl,v 1.23 2005/02/08 16:51:03 travis%sedsystems.ca Exp $
 ###############################################################
 
 # 02/12/2000 (SML)
@@ -1085,7 +1085,7 @@ END
     my $reporter = "";
 
     my $query = "insert into bugs (\n" . join(",\n", @used_fields ) . 
-       ", bug_status, creation_ts, everconfirmed) values ( ";
+       ", bug_status, creation_ts, delta_ts, everconfirmed) values ( ";
     
     # 'Yuck'. Then again, this whole file should be rewritten anyway...
     $query =~ s/product/product_id/;
@@ -1140,7 +1140,7 @@ END
       $state = SqlQuote("NEW");
     }
 
-    $query .=  $state . ", \'$bug_when\', $ever_confirmed)\n";
+    $query .=  $state . ", \'$bug_when\', \'$bug_when\', $ever_confirmed)\n";
 #    $query .=  SqlQuote( "NEW" ) . ", now(), " . SqlQuote($comment) . " )\n";
 
     SendSQL("SELECT userid FROM profiles WHERE login_name=\'$reporter\'");
index dbd47ea7a1aa4c0b2574b1468e8f550daf33761f..ed8231dfc7ce0aa6737fc5b9989c4a302716f305 100644 (file)
@@ -208,6 +208,7 @@ def process_jitterbug(filename):
                     "bug_severity='normal',"  \
                     "bug_status=%s," \
                     "creation_ts=%s,"  \
+                    "delta_ts=%s,"  \
                     "short_desc=%s," \
                     "product=%s," \
                     "rep_platform='All'," \
@@ -219,6 +220,7 @@ def process_jitterbug(filename):
                     [ current['number'],
                       bug_status,
                       time.strftime("%Y-%m-%d %H:%M:%S", current['date-reported'][:9]),
+                      time.strftime("%Y-%m-%d %H:%M:%S", current['date-reported'][:9]),
                       current['short-description'],
                       product,
                       reporter,
index 1603851045e721da30d2bdd4897bad1fa8f41b6c..6d47fc6af414f419ff33737dce9498a33b348959 100755 (executable)
@@ -548,8 +548,7 @@ if ($action eq 'update') {
         trick_taint($milestoneold);
 
         $dbh->do('UPDATE bugs
-                  SET target_milestone = ?,
-                  delta_ts = delta_ts
+                  SET target_milestone = ?
                   WHERE target_milestone = ?
                   AND product_id = ?',
                  undef,
index d619909aeb1abe025bbdf0a3abead319abd3b3b5..3faa88563f3cda52751b7bb852d4773551642a6d 100755 (executable)
@@ -1175,12 +1175,12 @@ if ($action eq 'updategroupcontrols') {
             my ($removed, $timestamp) = FetchSQLData();
             LogActivityEntry($bugid, "bug_group", $removed, "",
                              $::userid, $timestamp);
+            my $diffed = "";
             if ($mailiscurrent != 0) {
-                SendSQL("UPDATE bugs SET lastdiffed = " . SqlQuote($timestamp)
-                     . " WHERE bug_id = $bugid");
+                $diffed = ", lastdiffed = " . SqlQuote($timestamp);
             }
-            SendSQL("UPDATE bugs SET delta_ts = " . SqlQuote($timestamp)
-                 . " WHERE bug_id = $bugid");
+            SendSQL("UPDATE bugs SET delta_ts = " . SqlQuote($timestamp) .
+                    $diffed . " WHERE bug_id = $bugid");
             PopGlobalSQLState();
             $count++;
         }
@@ -1209,12 +1209,12 @@ if ($action eq 'updategroupcontrols') {
             my ($added, $timestamp) = FetchSQLData();
             LogActivityEntry($bugid, "bug_group", "", $added,
                              $::userid, $timestamp);
+            my $diffed = "";
             if ($mailiscurrent != 0) {
-                SendSQL("UPDATE bugs SET lastdiffed = " . SqlQuote($timestamp)
-                     . " WHERE bug_id = $bugid");
+                $diffed = ", lastdiffed = " . SqlQuote($timestamp);
             }
-            SendSQL("UPDATE bugs SET delta_ts = " . SqlQuote($timestamp)
-                 . " WHERE bug_id = $bugid");
+            SendSQL("UPDATE bugs SET delta_ts = " . SqlQuote($timestamp) .
+                    $diffed . " WHERE bug_id = $bugid");
             PopGlobalSQLState();
             $count++;
         }
index e4cf47e2a103c7b0e3f7c892711dde3d92343232..2173470dc3637c7049a71fb7c573573aabdfe1b2 100755 (executable)
@@ -418,8 +418,7 @@ if ($action eq 'update') {
             exit;
         }
         SendSQL("UPDATE bugs
-                 SET version=" . SqlQuote($version) . ",
-                 delta_ts = delta_ts
+                 SET version=" . SqlQuote($version) . "
                  WHERE version=" . SqlQuote($versionold) . "
                    AND product_id = $product_id");
         SendSQL("UPDATE versions
index 7a0ccebaa11b4ecb0eac76e27492fe9420863534..f4a11e72f21ca2e3b4bda56904bb06be49123e56 100644 (file)
@@ -137,7 +137,7 @@ sub AppendComment {
         "VALUES($bugid, $whoid, $timestamp, " . SqlQuote($comment) . ", " . 
         $privacyval . ", " . SqlQuote($work_time) . ")");
 
-    SendSQL("UPDATE bugs SET delta_ts = now() WHERE bug_id = $bugid");
+    SendSQL("UPDATE bugs SET delta_ts = $timestamp WHERE bug_id = $bugid");
 }
 
 sub GetFieldID {
@@ -1269,8 +1269,7 @@ sub RemoveVotes {
         SendSQL("SELECT SUM(vote_count) FROM votes WHERE bug_id = $id");
         my $v = FetchOneColumn();
         $v ||= 0;
-        SendSQL("UPDATE bugs SET votes = $v, delta_ts = delta_ts " .
-                "WHERE bug_id = $id");
+        SendSQL("UPDATE bugs SET votes = $v WHERE bug_id = $id");
     }
 }
 
index 277681a35e003a09ca73a5029e0529dc560fbbd9..21d962d414c9a6b180c8040670d9190965cf425c 100755 (executable)
@@ -339,13 +339,21 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
 
   my @query = ();
   my @values = ();
-  foreach my $field ( qw(creation_ts delta_ts status_whiteboard) ) {
+  foreach my $field ( qw(creation_ts status_whiteboard) ) {
       if ( (defined $bug_fields{$field}) && ($bug_fields{$field}) ){
         push (@query, "$field");
         push (@values, SqlQuote($bug_fields{$field}));
       }
   }
 
+  push (@query, "delta_ts");
+  if ( (defined $bug_fields{'delta_ts'}) && ($bug_fields{'delta_ts'}) ){
+      push (@values, SqlQuote($bug_fields{'delta_ts'}));
+  }
+  else {
+      push (@values, "NOW()");
+  }
+
   if ( (defined $bug_fields{'bug_file_loc'}) && ($bug_fields{'bug_file_loc'}) ){
       push (@query, "bug_file_loc");
       push (@values, SqlQuote($bug_fields{'bug_file_loc'}));
diff --git a/move.pl b/move.pl
index 328671f8170898af8be2cbe8a933626fedbbbfd0..7747baaed1481dec3c56501ef851b03dc2c7e8ed 100755 (executable)
--- a/move.pl
+++ b/move.pl
@@ -122,8 +122,10 @@ foreach my $id (split(/:/, scalar($cgi->param('buglist')))) {
             "(bug_id,who,bug_when,fieldid,removed,added) VALUES " .
             "($id,$exporterid,now(),$fieldid,'$cur_res','MOVED')");
 
-    SendSQL("UPDATE bugs SET bug_status =\"RESOLVED\" where bug_id=\"$id\"");
-    SendSQL("UPDATE bugs SET resolution =\"MOVED\" where bug_id=\"$id\"");
+    SendSQL("UPDATE bugs SET bug_status =\"RESOLVED\",
+                             resolution =\"MOVED\",
+                             delta_ts = NOW()
+              WHERE bug_id=\"$id\"");
 
     my $comment = "";
     if (defined $cgi->param('comment') && $cgi->param('comment') !~ /^\s*$/) {
index 97f788dc67e6544a8777ab6c1f0f53549090f886..0f5abddb267312e0c1740a4a2ee692dc74393f18 100755 (executable)
@@ -321,9 +321,14 @@ if (UserInGroup("editbugs") && defined($::FORM{'dependson'})) {
     }
 }
 
+# get current time
+SendSQL("SELECT NOW()");
+my $timestamp = FetchOneColumn();
+my $sql_timestamp = SqlQuote($timestamp);
+
 # Build up SQL string to add bug.
 my $sql = "INSERT INTO bugs " . 
-  "(" . join(",", @used_fields) . ", reporter, creation_ts, " .
+  "(" . join(",", @used_fields) . ", reporter, creation_ts, delta_ts, " .
   "estimated_time, remaining_time, deadline) " .
   "VALUES (";
 
@@ -337,7 +342,7 @@ $comment = trim($comment);
 # OK except for the fact that it causes e-mail to be suppressed.
 $comment = $comment ? $comment : " ";
 
-$sql .= "$::userid, now(), ";
+$sql .= "$::userid, $sql_timestamp, $sql_timestamp, ";
 
 # Time Tracking
 if (UserInGroup(Param("timetrackinggroup")) &&
@@ -414,9 +419,6 @@ while (MoreSQLData()) {
 # Add the bug report to the DB.
 SendSQL($sql);
 
-SendSQL("select now()");
-my $timestamp = FetchOneColumn();
-
 # Get the bug ID back.
 SendSQL("select LAST_INSERT_ID()");
 my $id = FetchOneColumn();
@@ -434,8 +436,8 @@ if (Param("insidergroup") && UserInGroup(Param("insidergroup"))) {
 }
 
 SendSQL("INSERT INTO longdescs (bug_id, who, bug_when, thetext, isprivate) 
-         VALUES ($id, " . SqlQuote($user->id) . ", " . SqlQuote($timestamp) . 
-        ", " . SqlQuote($comment) . ", $privacy)");
+         VALUES ($id, " . SqlQuote($user->id) . ", $sql_timestamp, " .\r
+        SqlQuote($comment) . ", $privacy)");
 
 # Insert the cclist into the database
 foreach my $ccid (keys(%ccids)) {
@@ -456,8 +458,8 @@ if (UserInGroup("editbugs")) {
         while (MoreSQLData()) {
             push (@list, FetchOneColumn());
         }
-        SendSQL("UPDATE bugs SET keywords = " .
-                SqlQuote(join(', ', @list)) .
+        SendSQL("UPDATE bugs SET delta_ts = $sql_timestamp," .
+                " keywords = " . SqlQuote(join(', ', @list)) .
                 " WHERE bug_id = $id");
     }
     if (defined $::FORM{'dependson'}) {
index a04fe62b2336ddf258ce503abf4f35e3df8934f6..e43bf42eeb0e9fd241fc2e28814f40849edc3cef 100755 (executable)
@@ -1111,14 +1111,15 @@ sub FindWrapPoint {
 }
 
 sub LogDependencyActivity {
-    my ($i, $oldstr, $target, $me) = (@_);
+    my ($i, $oldstr, $target, $me, $timestamp) = (@_);
+    my $sql_timestamp = SqlQuote($timestamp);
     my $newstr = SnapShotDeps($i, $target, $me);
     if ($oldstr ne $newstr) {
         # Figure out what's really different...
         my ($removed, $added) = diff_strings($oldstr, $newstr);
         LogActivityEntry($i,$target,$removed,$added,$whoid,$timestamp);
         # update timestamp on target bug so midairs will be triggered
-        SendSQL("UPDATE bugs SET delta_ts=NOW() WHERE bug_id=$i");
+        SendSQL("UPDATE bugs SET delta_ts = $sql_timestamp WHERE bug_id = $i");
         $bug_changed = 1;
         return 1;
     }
@@ -1350,6 +1351,7 @@ foreach my $id (@idlist) {
 
     SendSQL("select now()");
     $timestamp = FetchOneColumn();
+    my $sql_timestamp = SqlQuote($timestamp);\r
 
     my $work_time;
     if (UserInGroup(Param('timetrackinggroup'))) {
@@ -1402,7 +1404,7 @@ foreach my $id (@idlist) {
             while (MoreSQLData()) {
                 push(@list, FetchOneColumn());
             }
-            SendSQL("UPDATE bugs SET keywords = " .
+            SendSQL("UPDATE bugs SET delta_ts = $sql_timestamp, keywords = " .
                     SqlQuote(join(', ', @list)) .
                     " WHERE bug_id = $id");
         }
@@ -1557,9 +1559,9 @@ foreach my $id (@idlist) {
                     SendSQL("insert into dependencies ($me, $target) values ($id, $i)");
                 }
                 foreach my $k (@keys) {
-                    LogDependencyActivity($k, $snapshot{$k}, $me, $target);
+                    LogDependencyActivity($k, $snapshot{$k}, $me, $target, $timestamp);
                 }
-                LogDependencyActivity($id, $oldsnap, $target, $me);
+                LogDependencyActivity($id, $oldsnap, $target, $me, $timestamp);
                 $check_dep_bugs = 1;
             }
 
@@ -1770,7 +1772,7 @@ foreach my $id (@idlist) {
         Bugzilla::Flag::process($target, $timestamp, \%::FORM);
     }
     if ($bug_changed) {
-        SendSQL("UPDATE bugs SET delta_ts = " . SqlQuote($timestamp) . " WHERE bug_id = $id");
+        SendSQL("UPDATE bugs SET delta_ts = $sql_timestamp WHERE bug_id = $id");
     }
     SendSQL("UNLOCK TABLES");
 
@@ -1803,7 +1805,10 @@ foreach my $id (@idlist) {
             SendSQL("INSERT INTO cc (who, bug_id) VALUES ($reporter, " . SqlQuote($duplicate) . ")");
         }
         # Bug 171639 - Duplicate notifications do not need to be private. 
-        AppendComment($duplicate, Bugzilla->user->login, "*** Bug $::FORM{'id'} has been marked as a duplicate of this bug. ***", 0);
+        AppendComment($duplicate, Bugzilla->user->login,
+                      "*** Bug $::FORM{'id'} has been marked as a duplicate of this bug. ***",
+                      0, $timestamp);
+
         CheckFormFieldDefined(\%::FORM,'comment');
         SendSQL("INSERT INTO duplicates VALUES ($duplicate, $::FORM{'id'})");
         
index d9c6af221ce75a80cc24973abd61e38f1207f56f..7bd42d22d59e1e2fbb9dc8d6cf7c020194295d2d 100755 (executable)
@@ -96,7 +96,7 @@ PutHeader("Bugzilla Sanity Check");
 if (defined $cgi->param('rebuildvotecache')) {
     Status("OK, now rebuilding vote cache.");
     SendSQL("LOCK TABLES bugs WRITE, votes READ");
-    SendSQL("UPDATE bugs SET votes = 0, delta_ts = delta_ts");
+    SendSQL("UPDATE bugs SET votes = 0");
     SendSQL("SELECT bug_id, SUM(vote_count) FROM votes GROUP BY bug_id");
     my %votes;
     while (@row = FetchSQLData()) {
@@ -104,7 +104,7 @@ if (defined $cgi->param('rebuildvotecache')) {
         $votes{$id} = $v;
     }
     foreach my $id (keys %votes) {
-        SendSQL("UPDATE bugs SET votes = $votes{$id}, delta_ts = delta_ts WHERE bug_id = $id");
+        SendSQL("UPDATE bugs SET votes = $votes{$id} WHERE bug_id = $id");
     }
     SendSQL("UNLOCK TABLES");
     Status("Vote cache has been rebuilt.");
@@ -586,8 +586,7 @@ if (@badbugs) {
             if (exists($realk{$b})) {
                 $k = $realk{$b};
             }
-            SendSQL("UPDATE bugs SET delta_ts = delta_ts, keywords = " .
-                    SqlQuote($k) .
+            SendSQL("UPDATE bugs SET keywords = " . SqlQuote($k) .
                     " WHERE bug_id = $b");
         }
         Status("Keyword cache fixed.");
index 3c61f6061e01775f359fc1db7d4ac97092eca23a..7e2caf2a8bcb8176eb5914136aa078b7c088a464 100755 (executable)
--- a/votes.cgi
+++ b/votes.cgi
@@ -344,8 +344,7 @@ sub record_votes {
     foreach my $id (keys %affected) {
         SendSQL("SELECT sum(vote_count) FROM votes WHERE bug_id = $id");
         my $v = FetchOneColumn() || 0;
-        SendSQL("UPDATE bugs SET votes = $v, delta_ts=delta_ts 
-                 WHERE bug_id = $id");
+        SendSQL("UPDATE bugs SET votes = $v WHERE bug_id = $id");
         my $confirmed = CheckIfVotedConfirmed($id, $who);
         $vars->{'header_done'} = 1 if $confirmed;
     }