aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-02-20 15:53:16 +0000
committermkanat%kerio.com <>2005-02-20 15:53:16 +0000
commite547dd6d7b7b9a3c2135c56dd6b7a433743fd4b1 (patch)
tree179cd1f21b8e26b2cf2feec6ebfe30ddbd33afdd
parent335b8c125f821a96ddfd769163c92c1d74ce62f6 (diff)
downloadbugs-e547dd6d7b7b9a3c2135c56dd6b7a433743fd4b1.tar
bugs-e547dd6d7b7b9a3c2135c56dd6b7a433743fd4b1.tar.gz
bugs-e547dd6d7b7b9a3c2135c56dd6b7a433743fd4b1.tar.bz2
bugs-e547dd6d7b7b9a3c2135c56dd6b7a433743fd4b1.tar.xz
bugs-e547dd6d7b7b9a3c2135c56dd6b7a433743fd4b1.zip
Bug 280499: Replace "TO_DAYS()" with Bugzilla::DB function call
Patch By Tomas Kopal <Tomas.Kopal@altap.cz> r=mkanat, a=justdave
-rw-r--r--Bugzilla/Auth/Login/WWW/CGI.pm7
-rw-r--r--Bugzilla/Chart.pm6
-rw-r--r--Bugzilla/Search.pm3
-rw-r--r--Bugzilla/Token.pm5
-rwxr-xr-xchecksetup.pl5
-rwxr-xr-xcollectstats.pl9
-rwxr-xr-xwhineatnews.pl10
7 files changed, 26 insertions, 19 deletions
diff --git a/Bugzilla/Auth/Login/WWW/CGI.pm b/Bugzilla/Auth/Login/WWW/CGI.pm
index 98999a368..42e454f86 100644
--- a/Bugzilla/Auth/Login/WWW/CGI.pm
+++ b/Bugzilla/Auth/Login/WWW/CGI.pm
@@ -45,6 +45,7 @@ sub login {
}
my $cgi = Bugzilla->cgi;
+ my $dbh = Bugzilla->dbh;
# First, try the actual login method against form variables
my $username = $cgi->param("Bugzilla_login");
@@ -67,7 +68,6 @@ sub login {
# subsequent login
trick_taint($ipaddr);
- my $dbh = Bugzilla->dbh;
$dbh->do("INSERT INTO logincookies (userid, ipaddr, lastused)
VALUES (?, ?, NOW())",
undef,
@@ -159,8 +159,9 @@ sub login {
# This seems like as good as time as any to get rid of old
# crufty junk in the logincookies table. Get rid of any entry
# that hasn't been used in a month.
- Bugzilla->dbh->do("DELETE FROM logincookies " .
- "WHERE TO_DAYS(NOW()) - TO_DAYS(lastused) > 30");
+ $dbh->do("DELETE FROM logincookies WHERE " .
+ $dbh->sql_to_days('NOW()') . " - " .
+ $dbh->sql_to_days('lastused') . " > 30");
exit;
}
diff --git a/Bugzilla/Chart.pm b/Bugzilla/Chart.pm
index 90c1ad16f..0836adde3 100644
--- a/Bugzilla/Chart.pm
+++ b/Bugzilla/Chart.pm
@@ -229,9 +229,9 @@ sub readData {
}
# Prepare the query which retrieves the data for each series
- my $query = "SELECT TO_DAYS(series_date) - " .
- " TO_DAYS(FROM_UNIXTIME($datefrom)), " .
- "series_value FROM series_data " .
+ my $query = "SELECT " . $dbh->sql_to_days('series_date') . " - " .
+ $dbh->sql_to_days('FROM_UNIXTIME($datefrom)') .
+ ", series_value FROM series_data " .
"WHERE series_id = ? " .
"AND series_date >= FROM_UNIXTIME($datefrom)";
if ($dateto) {
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index 6584f1080..82cbb9aa6 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -797,7 +797,8 @@ sub init {
},
"^changedin," => sub {
- $f = "(to_days(now()) - to_days(bugs.delta_ts))";
+ $f = "(" . $dbh->sql_to_days('NOW()') . " - " .
+ $dbh->sql_to_days('bugs.delta_ts') . ")";
},
"^component,(?!changed)" => sub {
diff --git a/Bugzilla/Token.pm b/Bugzilla/Token.pm
index 548430847..4c70d4bad 100644
--- a/Bugzilla/Token.pm
+++ b/Bugzilla/Token.pm
@@ -163,8 +163,9 @@ sub IssuePasswordToken {
sub CleanTokenTable {
my $dbh = Bugzilla->dbh;
$dbh->bz_lock_tables('tokens WRITE');
- &::SendSQL("DELETE FROM tokens
- WHERE TO_DAYS(NOW()) - TO_DAYS(issuedate) >= " . $maxtokenage);
+ &::SendSQL("DELETE FROM tokens WHERE " .
+ $dbh->sql_to_days('NOW()') . " - " .
+ $dbh->sql_to_days('issuedate') . " >= " . $maxtokenage);
$dbh->bz_unlock_tables();
}
diff --git a/checksetup.pl b/checksetup.pl
index 1185eedcf..9c35b5a98 100755
--- a/checksetup.pl
+++ b/checksetup.pl
@@ -2289,8 +2289,9 @@ AddFDef("attachments.isprivate", "Attachment is private", 0);
AddFDef("target_milestone", "Target Milestone", 0);
AddFDef("delta_ts", "Last changed date", 0);
-AddFDef("(to_days(now()) - to_days(bugs.delta_ts))", "Days since bug changed",
- 0);
+AddFDef("(" . $dbh->sql_to_days('NOW()') . " - " .
+ $dbh->sql_to_days('bugs.delta_ts') . ")",
+ "Days since bug changed", 0);
AddFDef("longdesc", "Comment", 0);
AddFDef("alias", "Alias", 0);
AddFDef("everconfirmed", "Ever Confirmed", 0);
diff --git a/collectstats.pl b/collectstats.pl
index cf863f405..ae44b0b75 100755
--- a/collectstats.pl
+++ b/collectstats.pl
@@ -283,10 +283,11 @@ sub regenerate_stats {
# Determine the start date from the date the first bug in the
# database was created, and the end date from the current day.
# If there were no bugs in the search, return early.
- SendSQL("SELECT to_days(creation_ts) AS start, " .
- "to_days(current_date) AS end, " .
- "to_days('1970-01-01') " .
- "FROM bugs $from_product WHERE to_days(creation_ts) != 'NULL' " .
+ SendSQL("SELECT " . $dbh->sql_to_days('creation_ts') . " AS start, " .
+ $dbh->sql_to_days('current_date') . " AS end, " .
+ $dbh->sql_to_days("'1970-01-01'") .
+ " FROM bugs $from_product WHERE " .
+ $dbh->sql_to_days('creation_ts') . " != 'NULL' " .
$and_product .
"ORDER BY start " . $dbh->sql_limit(1));
diff --git a/whineatnews.pl b/whineatnews.pl
index 8e73e1b6d..d90e775fa 100755
--- a/whineatnews.pl
+++ b/whineatnews.pl
@@ -33,10 +33,12 @@ require "globals.pl";
use Bugzilla::BugMail;
-SendSQL("select bug_id,short_desc,login_name from bugs,profiles where " .
- "(bug_status = 'NEW' or bug_status = 'REOPENED') and " .
- "to_days(now()) - to_days(delta_ts) > " . Param('whinedays') .
- " and userid=assigned_to order by bug_id");
+my $dbh = Bugzilla->dbh;
+SendSQL("SELECT bug_id, short_desc, login_name FROM bugs, profiles WHERE " .
+ "(bug_status = 'NEW' OR bug_status = 'REOPENED') AND " .
+ $dbh->sql_to_days('NOW()') . " - " .
+ $dbh->sql_to_days('delta_ts') . " > " . Param('whinedays') .
+ " AND userid = assigned_to ORDER BY bug_id");
my %bugs;
my %desc;