]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 280500: Replace "DATE_FORMAT()" with Bugzilla::DB function call
authormkanat%kerio.com <>
Fri, 25 Feb 2005 07:37:47 +0000 (07:37 +0000)
committermkanat%kerio.com <>
Fri, 25 Feb 2005 07:37:47 +0000 (07:37 +0000)
Patch By Tomas Kopal <Tomas.Kopal@altap.cz> r=mkanat, a=myk

Bugzilla/Attachment.pm
Bugzilla/Bug.pm
CGI.pl
attachment.cgi
buglist.cgi
globals.pl
request.cgi
whine.pl

index 5f491f3155c23092076836bd5ad820458b3181be..8be92dcf253438a94d7a2a4e7a5d9adbf9a5f88a 100644 (file)
@@ -67,6 +67,8 @@ sub query
   # "attachments" variable.
   my ($bugid) = @_;
 
+  my $dbh = Bugzilla->dbh;
+
   my $in_editbugs = &::UserInGroup("editbugs");
   &::SendSQL("SELECT product_id
            FROM bugs 
@@ -76,9 +78,9 @@ sub query
 
   # Retrieve a list of attachments for this bug and write them into an array
   # of hashes in which each hash represents a single attachment.
-  &::SendSQL("
-              SELECT attach_id, DATE_FORMAT(creation_ts, '%Y.%m.%d %H:%i'),
-              mimetype, description, ispatch, isobsolete, isprivate, 
+  &::SendSQL("SELECT attach_id, " .
+             $dbh->sql_date_format('creation_ts', '%Y.%m.%d %H:%i') .
+             ", mimetype, description, ispatch, isobsolete, isprivate, 
               submitter_id, LENGTH(thedata)
               FROM attachments WHERE bug_id = $bugid ORDER BY attach_id
             ");
index 5e25820e9baae21af3123091733b60269b0c7938..2f1df58bdfafdbf2ce7f1a50a1f90971a2f71e55 100755 (executable)
@@ -144,18 +144,19 @@ sub initBug  {
       rep_platform, op_sys, bug_status, resolution, priority,
       bug_severity, bugs.component_id, components.name, assigned_to,
       reporter, bug_file_loc, short_desc, target_milestone,
-      qa_contact, status_whiteboard,
-      DATE_FORMAT(creation_ts,'%Y.%m.%d %H:%i'),
+      qa_contact, status_whiteboard, " .
+      $dbh->sql_date_format('creation_ts', '%Y.%m.%d %H:%i') . ",
       delta_ts, COALESCE(SUM(votes.vote_count), 0),
       reporter_accessible, cclist_accessible,
-      estimated_time, remaining_time, DATE_FORMAT(deadline,'%Y-%m-%d')
-    from bugs left join votes using(bug_id),
+      estimated_time, remaining_time, " .
+      $dbh->sql_date_format('deadline', '%Y-%m-%d') . ",
+    FROM bugs LEFT JOIN votes using(bug_id),
       classifications, products, components
     WHERE bugs.bug_id = ?
       AND classifications.id = products.classification_id
       AND products.id = bugs.product_id
       AND components.id = bugs.component_id
-    group by bugs.bug_id";
+    GROUP BY bugs.bug_id";
 
   my $bug_sth = $dbh->prepare($query);
   $bug_sth->execute($bug_id);
@@ -534,11 +535,11 @@ sub GetComments {
     my @comments;
     my $sth = $dbh->prepare(
             "SELECT  profiles.realname AS name, profiles.login_name AS email,
-                     date_format(longdescs.bug_when,'%Y.%m.%d %H:%i') AS time,
-                     longdescs.thetext AS body, longdescs.work_time,
+            " . $dbh->sql_date_format('longdescs.bug_when', '%Y.%m.%d %H:%i') . "
+               AS time, longdescs.thetext AS body, longdescs.work_time,
                      isprivate, already_wrapped,
-                     date_format(longdescs.bug_when,'%Y%m%d%H%i%s')
-            FROM     longdescs, profiles
+            " . $dbh->sql_date_format('longdescs.bug_when', '%Y%m%d%H%i%s') . "
+             FROM    longdescs, profiles
             WHERE    profiles.userid = longdescs.who
               AND    longdescs.bug_id = ?
             ORDER BY longdescs.bug_when");
diff --git a/CGI.pl b/CGI.pl
index 1a8f09c2fa984223aa0c8f32e27cc2af0f536e1d..1b556bc71bafe7b3afb276b2e6edf4e491252db0 100644 (file)
--- a/CGI.pl
+++ b/CGI.pl
@@ -317,6 +317,7 @@ sub LogActivityEntry {
 sub GetBugActivity {
     my ($id, $starttime) = (@_);
     my $datepart = "";
+    my $dbh = Bugzilla->dbh;
 
     die "Invalid id: $id" unless $id=~/^\s*\d+\s*$/;
 
@@ -333,9 +334,9 @@ sub GetBugActivity {
     my $query = "
         SELECT COALESCE(fielddefs.description, bugs_activity.fieldid),
                 fielddefs.name,
-                bugs_activity.attach_id,
-                DATE_FORMAT(bugs_activity.bug_when,'%Y.%m.%d %H:%i:%s'),
-                bugs_activity.removed, bugs_activity.added,
+                bugs_activity.attach_id, " .
+                $dbh->sql_date_format('bugs_activity.bug_when', '%Y.%m.%d %H:%i:%s') .
+                ", bugs_activity.removed, bugs_activity.added,
                 profiles.login_name
         FROM bugs_activity $suppjoins LEFT JOIN fielddefs ON 
                                      bugs_activity.fieldid = fielddefs.fieldid,
index 0a296609b7233c2902c2943c408ee8f581e3348b..92d127e1a1977dea36a9463fa31f1d11fdd8b91f 100755 (executable)
@@ -800,11 +800,14 @@ sub viewall
   # Retrieve the attachments from the database and write them into an array
   # of hashes where each hash represents one attachment.
     my $privacy = "";
+    my $dbh = Bugzilla->dbh;
+
     if (Param("insidergroup") && !(UserInGroup(Param("insidergroup")))) {
         $privacy = "AND isprivate < 1 ";
     }
-    SendSQL("SELECT attach_id, DATE_FORMAT(creation_ts, '%Y.%m.%d %H:%i'),
-            mimetype, description, ispatch, isobsolete, isprivate,
+    SendSQL("SELECT attach_id, " .
+            $dbh->sql_date_format('creation_ts', '%Y.%m.%d %H:%i') . ",
+            mimetype, description, ispatch, isobsolete, isprivate, 
             LENGTH(thedata)
             FROM attachments WHERE bug_id = $::FORM{'bugid'} $privacy 
             ORDER BY attach_id");
index fd01f10d5fa7c5efb0a432b8a7fbc55fe818cee1..bd9aa8af71cbff275ab7e6d6496a3d81679cddc7 100755 (executable)
@@ -505,7 +505,7 @@ DefineColumn("remaining_time"    , "bugs.remaining_time"        , "Remaining Hou
 DefineColumn("actual_time"       , "(SUM(ldtime.work_time)*COUNT(DISTINCT ldtime.bug_when)/COUNT(bugs.bug_id)) AS actual_time", "Actual Hours");
 DefineColumn("percentage_complete","(100*((SUM(ldtime.work_time)*COUNT(DISTINCT ldtime.bug_when)/COUNT(bugs.bug_id))/((SUM(ldtime.work_time)*COUNT(DISTINCT ldtime.bug_when)/COUNT(bugs.bug_id))+bugs.remaining_time))) AS percentage_complete", "% Complete"); 
 DefineColumn("relevance"         , "relevance"                  , "Relevance"        );
-DefineColumn("deadline"          , "DATE_FORMAT(bugs.deadline, '%Y-%m-%d')", "Deadline");
+DefineColumn("deadline"          , $dbh->sql_date_format('bugs.deadline', '%Y-%m-%d'), "Deadline");
 
 ################################################################################
 # Display Column Determination
index f6f15566d3d78a92e7a94a66759dd139233fa7c8..100c8fab6d790175a59f9e3063696a8dee0cb258 100644 (file)
@@ -971,7 +971,9 @@ sub GetLongDescriptionAsText {
     my $result = "";
     my $count = 0;
     my $anyprivate = 0;
-    my ($query) = ("SELECT profiles.login_name, DATE_FORMAT(longdescs.bug_when,'%Y.%m.%d %H:%i'), " .
+    my $dbh = Bugzilla->dbh;
+    my ($query) = ("SELECT profiles.login_name, " .
+                   $dbh->sql_date_format('longdescs.bug_when', '%Y.%m.%d %H:%i') . ", " .
                    "       longdescs.thetext, longdescs.isprivate, " .
                    "       longdescs.already_wrapped " .
                    "FROM   longdescs, profiles " .
index b4b7e67661dbc0fa1a1910dc3bca06f2a554882b..fa37344e2440d30a4539f6d692b076bcfd68c3b4 100755 (executable)
@@ -56,6 +56,7 @@ exit;
 
 sub queue {
     my $cgi = Bugzilla->cgi;
+    my $dbh = Bugzilla->dbh;
     
     validateStatus($cgi->param('status'));
     validateGroup($cgi->param('group'));
@@ -75,7 +76,7 @@ sub queue {
                 flags.attach_id, attachments.description,
                 requesters.realname, requesters.login_name,
                 requestees.realname, requestees.login_name,
-                DATE_FORMAT(flags.creation_date,'%Y.%m.%d %H:%i'),
+    " . $dbh->sql_date_format('flags.creation_date', '%Y.%m.%d %H:%i') . ",
     " . 
     # Select columns that help us weed out secure bugs to which the user
     # should not have access.
index 52fbe4e8271b7485503c1d67c11d1f8d6dbde833..97378a178826bc248959f1f165f3850c9f2fd3ff 100755 (executable)
--- a/whine.pl
+++ b/whine.pl
@@ -118,12 +118,16 @@ if (open(NOMAIL, '<', "$datadir/nomail")) {
 }
 
 # get the current date and time from the database
-$sth = $dbh->prepare( 'SELECT DATE_FORMAT( NOW(), "%y,%m,%e,%w,%k,%i")');
+$sth = $dbh->prepare('SELECT ' . $dbh->sql_date_format('NOW()', '%y,%m,%d,%a,%H,%i'));
 $sth->execute;
-my ($now_year, $now_month, $now_day, $now_weekday, $now_hour, $now_minute) =
+my ($now_year, $now_month, $now_day, $now_weekdayname, $now_hour, $now_minute) =
         split(',', $sth->fetchrow_array);
 $sth->finish;
 
+# As DBs have different days numbering, use day name and convert it
+# to the range 0-6
+my $now_weekday = index("SunMonTueWedThuFriSat", $now_weekdayname) / 3;
+
 my @daysinmonth = qw(0 31 28 31 30 31 30 31 31 30 31 30 31);
 # Alter February in case of a leap year.  This simple way to do it only
 # applies if you won't be looking at February of next year, which whining