Commit e547dd6d authored by mkanat%kerio.com's avatar mkanat%kerio.com

Bug 280499: Replace "TO_DAYS()" with Bugzilla::DB function call

Patch By Tomas Kopal <Tomas.Kopal@altap.cz> r=mkanat, a=justdave
parent 335b8c12
...@@ -45,6 +45,7 @@ sub login { ...@@ -45,6 +45,7 @@ sub login {
} }
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
# First, try the actual login method against form variables # First, try the actual login method against form variables
my $username = $cgi->param("Bugzilla_login"); my $username = $cgi->param("Bugzilla_login");
...@@ -67,7 +68,6 @@ sub login { ...@@ -67,7 +68,6 @@ sub login {
# subsequent login # subsequent login
trick_taint($ipaddr); trick_taint($ipaddr);
my $dbh = Bugzilla->dbh;
$dbh->do("INSERT INTO logincookies (userid, ipaddr, lastused) $dbh->do("INSERT INTO logincookies (userid, ipaddr, lastused)
VALUES (?, ?, NOW())", VALUES (?, ?, NOW())",
undef, undef,
...@@ -159,8 +159,9 @@ sub login { ...@@ -159,8 +159,9 @@ sub login {
# This seems like as good as time as any to get rid of old # 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 # crufty junk in the logincookies table. Get rid of any entry
# that hasn't been used in a month. # that hasn't been used in a month.
Bugzilla->dbh->do("DELETE FROM logincookies " . $dbh->do("DELETE FROM logincookies WHERE " .
"WHERE TO_DAYS(NOW()) - TO_DAYS(lastused) > 30"); $dbh->sql_to_days('NOW()') . " - " .
$dbh->sql_to_days('lastused') . " > 30");
exit; exit;
} }
......
...@@ -229,9 +229,9 @@ sub readData { ...@@ -229,9 +229,9 @@ sub readData {
} }
# Prepare the query which retrieves the data for each series # Prepare the query which retrieves the data for each series
my $query = "SELECT TO_DAYS(series_date) - " . my $query = "SELECT " . $dbh->sql_to_days('series_date') . " - " .
" TO_DAYS(FROM_UNIXTIME($datefrom)), " . $dbh->sql_to_days('FROM_UNIXTIME($datefrom)') .
"series_value FROM series_data " . ", series_value FROM series_data " .
"WHERE series_id = ? " . "WHERE series_id = ? " .
"AND series_date >= FROM_UNIXTIME($datefrom)"; "AND series_date >= FROM_UNIXTIME($datefrom)";
if ($dateto) { if ($dateto) {
......
...@@ -797,7 +797,8 @@ sub init { ...@@ -797,7 +797,8 @@ sub init {
}, },
"^changedin," => sub { "^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 { "^component,(?!changed)" => sub {
......
...@@ -163,8 +163,9 @@ sub IssuePasswordToken { ...@@ -163,8 +163,9 @@ sub IssuePasswordToken {
sub CleanTokenTable { sub CleanTokenTable {
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
$dbh->bz_lock_tables('tokens WRITE'); $dbh->bz_lock_tables('tokens WRITE');
&::SendSQL("DELETE FROM tokens &::SendSQL("DELETE FROM tokens WHERE " .
WHERE TO_DAYS(NOW()) - TO_DAYS(issuedate) >= " . $maxtokenage); $dbh->sql_to_days('NOW()') . " - " .
$dbh->sql_to_days('issuedate') . " >= " . $maxtokenage);
$dbh->bz_unlock_tables(); $dbh->bz_unlock_tables();
} }
......
...@@ -2289,8 +2289,9 @@ AddFDef("attachments.isprivate", "Attachment is private", 0); ...@@ -2289,8 +2289,9 @@ AddFDef("attachments.isprivate", "Attachment is private", 0);
AddFDef("target_milestone", "Target Milestone", 0); AddFDef("target_milestone", "Target Milestone", 0);
AddFDef("delta_ts", "Last changed date", 0); AddFDef("delta_ts", "Last changed date", 0);
AddFDef("(to_days(now()) - to_days(bugs.delta_ts))", "Days since bug changed", AddFDef("(" . $dbh->sql_to_days('NOW()') . " - " .
0); $dbh->sql_to_days('bugs.delta_ts') . ")",
"Days since bug changed", 0);
AddFDef("longdesc", "Comment", 0); AddFDef("longdesc", "Comment", 0);
AddFDef("alias", "Alias", 0); AddFDef("alias", "Alias", 0);
AddFDef("everconfirmed", "Ever Confirmed", 0); AddFDef("everconfirmed", "Ever Confirmed", 0);
......
...@@ -283,10 +283,11 @@ sub regenerate_stats { ...@@ -283,10 +283,11 @@ sub regenerate_stats {
# Determine the start date from the date the first bug in the # Determine the start date from the date the first bug in the
# database was created, and the end date from the current day. # database was created, and the end date from the current day.
# If there were no bugs in the search, return early. # If there were no bugs in the search, return early.
SendSQL("SELECT to_days(creation_ts) AS start, " . SendSQL("SELECT " . $dbh->sql_to_days('creation_ts') . " AS start, " .
"to_days(current_date) AS end, " . $dbh->sql_to_days('current_date') . " AS end, " .
"to_days('1970-01-01') " . $dbh->sql_to_days("'1970-01-01'") .
"FROM bugs $from_product WHERE to_days(creation_ts) != 'NULL' " . " FROM bugs $from_product WHERE " .
$dbh->sql_to_days('creation_ts') . " != 'NULL' " .
$and_product . $and_product .
"ORDER BY start " . $dbh->sql_limit(1)); "ORDER BY start " . $dbh->sql_limit(1));
......
...@@ -33,10 +33,12 @@ require "globals.pl"; ...@@ -33,10 +33,12 @@ require "globals.pl";
use Bugzilla::BugMail; use Bugzilla::BugMail;
SendSQL("select bug_id,short_desc,login_name from bugs,profiles where " . my $dbh = Bugzilla->dbh;
"(bug_status = 'NEW' or bug_status = 'REOPENED') and " . SendSQL("SELECT bug_id, short_desc, login_name FROM bugs, profiles WHERE " .
"to_days(now()) - to_days(delta_ts) > " . Param('whinedays') . "(bug_status = 'NEW' OR bug_status = 'REOPENED') AND " .
" and userid=assigned_to order by bug_id"); $dbh->sql_to_days('NOW()') . " - " .
$dbh->sql_to_days('delta_ts') . " > " . Param('whinedays') .
" AND userid = assigned_to ORDER BY bug_id");
my %bugs; my %bugs;
my %desc; my %desc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment