Commit 4910b3f9 authored by mkanat%kerio.com's avatar mkanat%kerio.com

Bug 285692: lastdiffed should use NULL instead of the "beginning of time"

Patch By Max Kanat-Alexander <mkanat@kerio.com> r=glob, a=myk
parent af17bfb2
...@@ -172,9 +172,6 @@ sub ProcessOneBug($) { ...@@ -172,9 +172,6 @@ sub ProcessOneBug($) {
$values{component} = get_component_name($values{component_id}); $values{component} = get_component_name($values{component_id});
my ($start, $end) = (@row); my ($start, $end) = (@row);
# $start and $end are considered safe because users can't touch them
trick_taint($start);
trick_taint($end);
my $cc_ref = Bugzilla->dbh->selectcol_arrayref( my $cc_ref = Bugzilla->dbh->selectcol_arrayref(
q{SELECT profiles.login_name FROM cc, profiles q{SELECT profiles.login_name FROM cc, profiles
...@@ -220,15 +217,16 @@ sub ProcessOneBug($) { ...@@ -220,15 +217,16 @@ sub ProcessOneBug($) {
my @diffs; my @diffs;
# If lastdiffed is NULL, then we don't limit the search on time.
my $when_restriction = $start ?
" AND bug_when > '$start' AND bug_when <= '$end'" : '';
SendSQL("SELECT profiles.login_name, fielddefs.description, " . SendSQL("SELECT profiles.login_name, fielddefs.description, " .
" bug_when, removed, added, attach_id, fielddefs.name " . " bug_when, removed, added, attach_id, fielddefs.name " .
"FROM bugs_activity, fielddefs, profiles " . "FROM bugs_activity, fielddefs, profiles " .
"WHERE bug_id = $id " . "WHERE bug_id = $id " .
" AND fielddefs.fieldid = bugs_activity.fieldid " . " AND fielddefs.fieldid = bugs_activity.fieldid " .
" AND profiles.userid = who " . " AND profiles.userid = who " .
" AND bug_when > '$start' " . $when_restriction .
" AND bug_when <= '$end' " .
"ORDER BY bug_when" "ORDER BY bug_when"
); );
...@@ -280,8 +278,7 @@ sub ProcessOneBug($) { ...@@ -280,8 +278,7 @@ sub ProcessOneBug($) {
" AND fielddefs.fieldid = bugs_activity.fieldid" . " AND fielddefs.fieldid = bugs_activity.fieldid" .
" AND (fielddefs.name = 'bug_status' " . " AND (fielddefs.name = 'bug_status' " .
" OR fielddefs.name = 'resolution') " . " OR fielddefs.name = 'resolution') " .
" AND bug_when > '$start' " . $when_restriction .
" AND bug_when <= '$end' " .
"ORDER BY bug_when, bug_id"); "ORDER BY bug_when, bug_id");
my $thisdiff = ""; my $thisdiff = "";
...@@ -829,7 +826,7 @@ sub NewProcessOnePerson ($$$$$$$$$$$$$) { ...@@ -829,7 +826,7 @@ sub NewProcessOnePerson ($$$$$$$$$$$$$) {
} }
} }
my $isnew = ($start !~ m/[1-9]/); my $isnew = !$start;
my %substs; my %substs;
......
...@@ -154,7 +154,7 @@ use constant ABSTRACT_SCHEMA => { ...@@ -154,7 +154,7 @@ use constant ABSTRACT_SCHEMA => {
# comes from the keywords table # comes from the keywords table
keywords => {TYPE => 'MEDIUMTEXT', NOTNULL => 1, keywords => {TYPE => 'MEDIUMTEXT', NOTNULL => 1,
DEFAULT => "''"}, DEFAULT => "''"},
lastdiffed => {TYPE => 'DATETIME', NOTNULL => 1}, lastdiffed => {TYPE => 'DATETIME'},
everconfirmed => {TYPE => 'BOOLEAN', NOTNULL => 1}, everconfirmed => {TYPE => 'BOOLEAN', NOTNULL => 1},
reporter_accessible => {TYPE => 'BOOLEAN', reporter_accessible => {TYPE => 'BOOLEAN',
NOTNULL => 1, DEFAULT => 'TRUE'}, NOTNULL => 1, DEFAULT => 'TRUE'},
......
...@@ -2180,7 +2180,7 @@ if ($dbh->bz_get_field_def('bugs_activity', 'field')) { ...@@ -2180,7 +2180,7 @@ if ($dbh->bz_get_field_def('bugs_activity', 'field')) {
# http://bugzilla.mozilla.org/show_bugs.cgi?id=71552 # http://bugzilla.mozilla.org/show_bugs.cgi?id=71552
if (!$dbh->bz_get_field_def('bugs', 'lastdiffed')) { if (!$dbh->bz_get_field_def('bugs', 'lastdiffed')) {
$dbh->bz_add_field('bugs', 'lastdiffed', 'datetime not null'); $dbh->bz_add_field('bugs', 'lastdiffed', 'datetime');
$dbh->do('UPDATE bugs SET lastdiffed = now(), delta_ts = delta_ts'); $dbh->do('UPDATE bugs SET lastdiffed = now(), delta_ts = delta_ts');
} }
...@@ -3846,10 +3846,13 @@ $dbh->bz_change_field_type('bugs', 'votes', 'mediumint not null default 0'); ...@@ -3846,10 +3846,13 @@ $dbh->bz_change_field_type('bugs', 'votes', 'mediumint not null default 0');
# 2005-03-03 travis@sedsystems.ca -- Bug 41972 # 2005-03-03 travis@sedsystems.ca -- Bug 41972
add_setting ("display_quips", {"on" => 1, "off" => 2 }, "on" ); add_setting ("display_quips", {"on" => 1, "off" => 2 }, "on" );
$dbh->bz_change_field_type('bugs', 'lastdiffed', 'datetime');
} # END LEGACY CHECKS } # END LEGACY CHECKS
# If you had to change the --TABLE-- definition in any way, then add your # If you had to change the --TABLE-- definition in any way, then add your
# differential change code *** A B O V E *** this comment. # differential change code *** A B O V E *** this comment.
# #
......
...@@ -30,8 +30,10 @@ use Bugzilla::Constants; ...@@ -30,8 +30,10 @@ use Bugzilla::Constants;
use Bugzilla::BugMail; use Bugzilla::BugMail;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
SendSQL("SELECT bug_id FROM bugs WHERE lastdiffed < delta_ts AND SendSQL("SELECT bug_id FROM bugs
delta_ts < NOW() - " . $dbh->sql_interval('30 minute') . WHERE lastdiffed IS NULL
OR lastdiffed < delta_ts AND delta_ts < NOW() - "
. $dbh->sql_interval('30 minute') .
" ORDER BY bug_id"); " ORDER BY bug_id");
my @list; my @list;
while (MoreSQLData()) { while (MoreSQLData()) {
......
...@@ -1187,7 +1187,7 @@ if ($action eq 'updategroupcontrols') { ...@@ -1187,7 +1187,7 @@ if ($action eq 'updategroupcontrols') {
LogActivityEntry($bugid, "bug_group", $removed, "", LogActivityEntry($bugid, "bug_group", $removed, "",
$::userid, $timestamp); $::userid, $timestamp);
my $diffed = ""; my $diffed = "";
if ($mailiscurrent != 0) { if ($mailiscurrent) {
$diffed = ", lastdiffed = " . SqlQuote($timestamp); $diffed = ", lastdiffed = " . SqlQuote($timestamp);
} }
SendSQL("UPDATE bugs SET delta_ts = " . SqlQuote($timestamp) . SendSQL("UPDATE bugs SET delta_ts = " . SqlQuote($timestamp) .
...@@ -1221,7 +1221,7 @@ if ($action eq 'updategroupcontrols') { ...@@ -1221,7 +1221,7 @@ if ($action eq 'updategroupcontrols') {
LogActivityEntry($bugid, "bug_group", "", $added, LogActivityEntry($bugid, "bug_group", "", $added,
$::userid, $timestamp); $::userid, $timestamp);
my $diffed = ""; my $diffed = "";
if ($mailiscurrent != 0) { if ($mailiscurrent) {
$diffed = ", lastdiffed = " . SqlQuote($timestamp); $diffed = ", lastdiffed = " . SqlQuote($timestamp);
} }
SendSQL("UPDATE bugs SET delta_ts = " . SqlQuote($timestamp) . SendSQL("UPDATE bugs SET delta_ts = " . SqlQuote($timestamp) .
......
...@@ -924,15 +924,16 @@ sub GetLongDescriptionAsText { ...@@ -924,15 +924,16 @@ sub GetLongDescriptionAsText {
"WHERE profiles.userid = longdescs.who " . "WHERE profiles.userid = longdescs.who " .
"AND longdescs.bug_id = $id "); "AND longdescs.bug_id = $id ");
if ($start && $start =~ /[1-9]/) { # $start will be undef for New bugs, and defined for pre-existing bugs.
# If $start is not all zeros, obtain the count-index if ($start) {
# If $start is not NULL, obtain the count-index
# of this comment for the leading "Comment #xxx" line.) # of this comment for the leading "Comment #xxx" line.)
$query .= "AND longdescs.bug_when > '$start'"; SendSQL("SELECT count(*) FROM longdescs " .
SendSQL("SELECT count(*) FROM longdescs WHERE bug_id = $id AND bug_when <= '$start'"); " WHERE bug_id = $id AND bug_when <= '$start'");
($count) = (FetchSQLData()); ($count) = (FetchSQLData());
}
if ($end) { $query .= " AND longdescs.bug_when > '$start'"
$query .= "AND longdescs.bug_when <= '$end'"; . " AND longdescs.bug_when <= '$end' ";
} }
$query .= "ORDER BY longdescs.bug_when"; $query .= "ORDER BY longdescs.bug_when";
......
...@@ -178,7 +178,8 @@ if (defined $cgi->param('rescanallBugMail')) { ...@@ -178,7 +178,8 @@ if (defined $cgi->param('rescanallBugMail')) {
require Bugzilla::BugMail; require Bugzilla::BugMail;
Status("OK, now attempting to send unsent mail"); Status("OK, now attempting to send unsent mail");
SendSQL("SELECT bug_id FROM bugs WHERE lastdiffed < delta_ts AND SendSQL("SELECT bug_id FROM bugs
WHERE (lastdiffed IS NULL OR lastdiffed < delta_ts) AND
delta_ts < now() - " . $dbh->sql_interval('30 minute') . delta_ts < now() - " . $dbh->sql_interval('30 minute') .
" ORDER BY bug_id"); " ORDER BY bug_id");
my @list; my @list;
...@@ -737,7 +738,7 @@ Status("Checking for unsent mail"); ...@@ -737,7 +738,7 @@ Status("Checking for unsent mail");
@badbugs = (); @badbugs = ();
SendSQL("SELECT bug_id " . SendSQL("SELECT bug_id " .
"FROM bugs WHERE lastdiffed < delta_ts AND ". "FROM bugs WHERE (lastdiffed IS NULL OR lastdiffed < delta_ts) AND " .
"delta_ts < now() - " . $dbh->sql_interval('30 minute') . "delta_ts < now() - " . $dbh->sql_interval('30 minute') .
" ORDER BY bug_id"); " ORDER BY bug_id");
......
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