Commit d9548f66 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 328438: Eliminate @::log_columns - Patch by Max Kanat-Alexander…

Bug 328438: Eliminate @::log_columns - Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit a=myk
parent f35e18b5
...@@ -54,6 +54,7 @@ use base qw(Exporter); ...@@ -54,6 +54,7 @@ use base qw(Exporter);
RemoveVotes CheckIfVotedConfirmed RemoveVotes CheckIfVotedConfirmed
LogActivityEntry LogActivityEntry
is_open_state is_open_state
editable_bug_fields
); );
##################################################################### #####################################################################
...@@ -731,6 +732,19 @@ sub AppendComment { ...@@ -731,6 +732,19 @@ sub AppendComment {
$dbh->do("UPDATE bugs SET delta_ts = ? WHERE bug_id = ?", $dbh->do("UPDATE bugs SET delta_ts = ? WHERE bug_id = ?",
undef, $timestamp, $bugid); undef, $timestamp, $bugid);
} }
# Represents which fields from the bugs table are handled by process_bug.cgi.
sub editable_bug_fields {
my @fields = Bugzilla->dbh->bz_table_columns('bugs');
foreach my $remove ("bug_id", "creation_ts", "delta_ts", "lastdiffed") {
my $location = lsearch(\@fields, $remove);
splice(@fields, $location, 1);
}
# Sorted because the old @::log_columns variable, which this replaces,
# was sorted.
return sort(@fields);
}
# This method is private and is not to be used outside of the Bug class. # This method is private and is not to be used outside of the Bug class.
sub EmitDependList { sub EmitDependList {
my ($myfield, $targetfield, $bug_id) = (@_); my ($myfield, $targetfield, $bug_id) = (@_);
......
...@@ -131,7 +131,7 @@ sub ProcessOneBug { ...@@ -131,7 +131,7 @@ sub ProcessOneBug {
} }
my %values = %{$dbh->selectrow_hashref( my %values = %{$dbh->selectrow_hashref(
'SELECT ' . join(',', @::log_columns) . ', 'SELECT ' . join(',', editable_bug_fields()) . ',
lastdiffed AS start, LOCALTIMESTAMP(0) AS end lastdiffed AS start, LOCALTIMESTAMP(0) AS end
FROM bugs WHERE bug_id = ?', FROM bugs WHERE bug_id = ?',
undef, $id)}; undef, $id)};
......
...@@ -748,10 +748,9 @@ ...@@ -748,10 +748,9 @@
</warning> </warning>
<para> <para>
For a list of possible field names, look in For a list of possible field names, look at the bugs table in the
<filename>data/versioncache</filename> for the list called database. If you need help writing custom rules for your organization,
<filename>@::log_columns</filename>. If you need help writing custom ask in the newsgroup.
rules for your organization, ask in the newsgroup.
</para> </para>
</section> </section>
......
...@@ -72,16 +72,6 @@ use File::Spec; ...@@ -72,16 +72,6 @@ use File::Spec;
sub GenerateVersionTable { sub GenerateVersionTable {
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
@::log_columns = $dbh->bz_table_columns('bugs');
foreach my $i ("bug_id", "creation_ts", "delta_ts", "lastdiffed") {
my $w = lsearch(\@::log_columns, $i);
if ($w >= 0) {
splice(@::log_columns, $w, 1);
}
}
@::log_columns = (sort(@::log_columns));
@::legal_priority = get_legal_field_values("priority"); @::legal_priority = get_legal_field_values("priority");
@::legal_severity = get_legal_field_values("bug_severity"); @::legal_severity = get_legal_field_values("bug_severity");
@::legal_platform = get_legal_field_values("rep_platform"); @::legal_platform = get_legal_field_values("rep_platform");
...@@ -116,8 +106,6 @@ sub GenerateVersionTable { ...@@ -116,8 +106,6 @@ sub GenerateVersionTable {
print $fh "#\n"; print $fh "#\n";
require Data::Dumper; require Data::Dumper;
print $fh (Data::Dumper->Dump([\@::log_columns],
['*::log_columns']));
print $fh (Data::Dumper->Dump([\@::legal_priority, \@::legal_severity, print $fh (Data::Dumper->Dump([\@::legal_priority, \@::legal_severity,
\@::legal_platform, \@::legal_opsys, \@::legal_platform, \@::legal_opsys,
......
...@@ -83,6 +83,8 @@ my $template = Bugzilla->template; ...@@ -83,6 +83,8 @@ my $template = Bugzilla->template;
my $vars = {}; my $vars = {};
$vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count(); $vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count();
my @editable_bug_fields = editable_bug_fields();
my $requiremilestone = 0; my $requiremilestone = 0;
###################################################################### ######################################################################
...@@ -1380,7 +1382,7 @@ my $delta_ts; ...@@ -1380,7 +1382,7 @@ my $delta_ts;
sub SnapShotBug { sub SnapShotBug {
my ($id) = (@_); my ($id) = (@_);
my @row = $dbh->selectrow_array(q{SELECT delta_ts, } . my @row = $dbh->selectrow_array(q{SELECT delta_ts, } .
join(',', @::log_columns).q{ FROM bugs WHERE bug_id = ?}, join(',', @editable_bug_fields).q{ FROM bugs WHERE bug_id = ?},
undef, $id); undef, $id);
$delta_ts = shift @row; $delta_ts = shift @row;
...@@ -1544,7 +1546,7 @@ foreach my $id (@idlist) { ...@@ -1544,7 +1546,7 @@ foreach my $id (@idlist) {
my @oldvalues = SnapShotBug($id); my @oldvalues = SnapShotBug($id);
my %oldhash; my %oldhash;
my %formhash; my %formhash;
foreach my $col (@::log_columns) { foreach my $col (@editable_bug_fields) {
# Consider NULL db entries to be equivalent to the empty string # Consider NULL db entries to be equivalent to the empty string
$oldvalues[$i] = defined($oldvalues[$i]) ? $oldvalues[$i] : ''; $oldvalues[$i] = defined($oldvalues[$i]) ? $oldvalues[$i] : '';
# Convert the deadline taken from the DB into the YYYY-MM-DD format # Convert the deadline taken from the DB into the YYYY-MM-DD format
...@@ -1570,7 +1572,7 @@ foreach my $id (@idlist) { ...@@ -1570,7 +1572,7 @@ foreach my $id (@idlist) {
$formhash{'bug_status'} = $oldhash{'bug_status'}; $formhash{'bug_status'} = $oldhash{'bug_status'};
} }
} }
foreach my $col (@::log_columns) { foreach my $col (@editable_bug_fields) {
# The 'resolution' field is checked by ChangeResolution(), # The 'resolution' field is checked by ChangeResolution(),
# i.e. only if we effectively use it. # i.e. only if we effectively use it.
next if ($col eq 'resolution'); next if ($col eq 'resolution');
...@@ -2046,7 +2048,7 @@ foreach my $id (@idlist) { ...@@ -2046,7 +2048,7 @@ foreach my $id (@idlist) {
my @newvalues = SnapShotBug($id); my @newvalues = SnapShotBug($id);
my %newhash; my %newhash;
$i = 0; $i = 0;
foreach my $col (@::log_columns) { foreach my $col (@editable_bug_fields) {
# Consider NULL db entries to be equivalent to the empty string # Consider NULL db entries to be equivalent to the empty string
$newvalues[$i] = defined($newvalues[$i]) ? $newvalues[$i] : ''; $newvalues[$i] = defined($newvalues[$i]) ? $newvalues[$i] : '';
# Convert the deadline to the YYYY-MM-DD format. # Convert the deadline to the YYYY-MM-DD format.
...@@ -2065,7 +2067,7 @@ foreach my $id (@idlist) { ...@@ -2065,7 +2067,7 @@ foreach my $id (@idlist) {
# $msgs will store emails which have to be sent to voters, if any. # $msgs will store emails which have to be sent to voters, if any.
my $msgs; my $msgs;
foreach my $c (@::log_columns) { foreach my $c (@editable_bug_fields) {
my $col = $c; # We modify it, don't want to modify array my $col = $c; # We modify it, don't want to modify array
# values in place. # values in place.
my $old = shift @oldvalues; my $old = shift @oldvalues;
......
...@@ -30,6 +30,7 @@ use lib "."; ...@@ -30,6 +30,7 @@ use lib ".";
require "globals.pl"; require "globals.pl";
use Bugzilla::Bug;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Search; use Bugzilla::Search;
use Bugzilla::User; use Bugzilla::User;
...@@ -44,7 +45,6 @@ use vars qw( ...@@ -44,7 +45,6 @@ use vars qw(
@legal_platform @legal_platform
@legal_priority @legal_priority
@legal_severity @legal_severity
@log_columns
); );
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
...@@ -253,7 +253,7 @@ push @chfields, "[Bug creation]"; ...@@ -253,7 +253,7 @@ push @chfields, "[Bug creation]";
# This is what happens when you have variables whose definition depends # This is what happens when you have variables whose definition depends
# on the DB schema, and then the underlying schema changes... # on the DB schema, and then the underlying schema changes...
foreach my $val (@::log_columns) { foreach my $val (editable_bug_fields()) {
if ($val eq 'classification_id') { if ($val eq 'classification_id') {
$val = 'classification'; $val = 'classification';
} elsif ($val eq 'product_id') { } elsif ($val eq 'product_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