Commit 311eb45d authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 330521: Remove @::legal_product, @::legal_components and…

Bug 330521: Remove @::legal_product, @::legal_components and @::legal_target_milestone - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat a=justdave
parent d19c2c52
...@@ -109,13 +109,6 @@ sub check_version { ...@@ -109,13 +109,6 @@ sub check_version {
return $version; return $version;
} }
sub distinct_names {
my $dbh = Bugzilla->dbh;
my $names = $dbh->selectcol_arrayref(
'SELECT DISTINCT value FROM versions ORDER BY value');
return @$names;
}
1; 1;
__END__ __END__
...@@ -179,17 +172,6 @@ Version.pm represents a Product Version object. ...@@ -179,17 +172,6 @@ Version.pm represents a Product Version object.
Returns: Bugzilla::Version object. Returns: Bugzilla::Version object.
=item C<distinct_names()>
Description: A utility function for getting all the
possible version values from the database,
regardless of what product they're in.
Returns a list with no duplicate versions.
Params: none
Returns: A list of strings (versions).
=back =back
=cut =cut
...@@ -32,15 +32,14 @@ ...@@ -32,15 +32,14 @@
use AnyDBM_File; use AnyDBM_File;
use strict; use strict;
use IO::Handle; use IO::Handle;
use vars @::legal_product;
use lib "."; use lib ".";
require "globals.pl"; require "globals.pl";
use Bugzilla::Search;
use Bugzilla::User;
use Bugzilla; use Bugzilla;
use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::Config qw(:DEFAULT $datadir);
use Bugzilla::Search;
use Bugzilla::User;
use Bugzilla::Product;
# Turn off output buffering (probably needed when displaying output feedback # Turn off output buffering (probably needed when displaying output feedback
# in the regenerate mode.) # in the regenerate mode.)
...@@ -64,8 +63,8 @@ if ($#ARGV >= 0 && $ARGV[0] eq "--regenerate") { ...@@ -64,8 +63,8 @@ if ($#ARGV >= 0 && $ARGV[0] eq "--regenerate") {
$regenerate = 1; $regenerate = 1;
} }
my @myproducts; my @myproducts = map {$_->name} Bugzilla::Product::get_all_products();
push( @myproducts, "-All-", @::legal_product ); unshift(@myproducts, "-All-");
my $tstart = time; my $tstart = time;
foreach (@myproducts) { foreach (@myproducts) {
......
...@@ -44,9 +44,6 @@ use vars ...@@ -44,9 +44,6 @@ use vars
@legal_platform @legal_platform
@legal_opsys @legal_opsys
@legal_resolution @legal_resolution
@legal_components
@legal_target_milestone
); );
# Use the global template variables defined in globals.pl # Use the global template variables defined in globals.pl
......
...@@ -38,6 +38,7 @@ use Bugzilla::Flag; ...@@ -38,6 +38,7 @@ use Bugzilla::Flag;
use Bugzilla::FlagType; use Bugzilla::FlagType;
use Bugzilla::Group; use Bugzilla::Group;
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Product;
my $template = Bugzilla->template; my $template = Bugzilla->template;
my $vars = {}; my $vars = {};
...@@ -49,9 +50,6 @@ $user->in_group('editcomponents') ...@@ -49,9 +50,6 @@ $user->in_group('editcomponents')
action => "edit", action => "edit",
object => "flagtypes"}); object => "flagtypes"});
# Suppress "used only once" warnings.
use vars qw(@legal_product @legal_components %components);
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $product_id; my $product_id;
my $component_id; my $component_id;
...@@ -128,17 +126,18 @@ sub list { ...@@ -128,17 +126,18 @@ sub list {
sub edit { sub edit {
$action eq 'enter' ? validateTargetType() : (my $id = validateID()); $action eq 'enter' ? validateTargetType() : (my $id = validateID());
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
# Get this installation's products and components. my @products = Bugzilla::Product::get_all_products();
GetVersionTable(); # We require all unique component names.
my %components;
# products and components and the function used to modify the components foreach my $product (@products) {
# menu when the products menu changes; used by the template to populate foreach my $component (@{$product->components}) {
# the menus and keep the components menu consistent with the products menu $components{$component->name} = 1;
$vars->{'products'} = \@::legal_product; }
$vars->{'components'} = \@::legal_components; }
$vars->{'components_by_product'} = \%::components; $vars->{'products'} = \@products;
$vars->{'components'} = [sort(keys %components)];
$vars->{'last_action'} = $cgi->param('action'); $vars->{'last_action'} = $cgi->param('action');
if ($cgi->param('action') eq 'enter' || $cgi->param('action') eq 'copy') { if ($cgi->param('action') eq 'enter' || $cgi->param('action') eq 'copy') {
$vars->{'action'} = "insert"; $vars->{'action'} = "insert";
...@@ -216,17 +215,21 @@ sub processCategoryChange { ...@@ -216,17 +215,21 @@ sub processCategoryChange {
my %inclusions = clusion_array_to_hash(\@inclusions); my %inclusions = clusion_array_to_hash(\@inclusions);
my %exclusions = clusion_array_to_hash(\@exclusions); my %exclusions = clusion_array_to_hash(\@exclusions);
# Get this installation's products and components. my @products = Bugzilla::Product::get_all_products();
GetVersionTable(); # We require all unique component names.
my %components;
foreach my $product (@products) {
foreach my $component (@{$product->components}) {
$components{$component->name} = 1;
}
}
$vars->{'products'} = \@products;
$vars->{'components'} = [sort(keys %components)];
# products and components; used by the template to populate the menus
# and keep the components menu consistent with the products menu
$vars->{'products'} = \@::legal_product;
$vars->{'components'} = \@::legal_components;
$vars->{'components_by_product'} = \%::components;
my @groups = Bugzilla::Group::get_all_groups(); my @groups = Bugzilla::Group::get_all_groups();
$vars->{'groups'} = \@groups; $vars->{'groups'} = \@groups;
$vars->{'action'} = $cgi->param('action'); $vars->{'action'} = $cgi->param('action');
my $type = {}; my $type = {};
foreach my $key ($cgi->param()) { $type->{$key} = $cgi->param($key) } foreach my $key ($cgi->param()) { $type->{$key} = $cgi->param($key) }
$type->{'inclusions'} = \%inclusions; $type->{'inclusions'} = \%inclusions;
......
...@@ -38,6 +38,7 @@ use Bugzilla::Util; ...@@ -38,6 +38,7 @@ use Bugzilla::Util;
use Bugzilla::Config qw(:DEFAULT ChmodDataFile $localconfig $datadir); use Bugzilla::Config qw(:DEFAULT ChmodDataFile $localconfig $datadir);
use Bugzilla::User; use Bugzilla::User;
use Bugzilla::Error; use Bugzilla::Error;
use Bugzilla::Product;
# Shut up misguided -w warnings about "used only once". For some reason, # Shut up misguided -w warnings about "used only once". For some reason,
# "use vars" chokes on me when I try it here. # "use vars" chokes on me when I try it here.
...@@ -46,13 +47,10 @@ sub globals_pl_sillyness { ...@@ -46,13 +47,10 @@ sub globals_pl_sillyness {
my $zz; my $zz;
$zz = @main::enterable_products; $zz = @main::enterable_products;
$zz = @main::legal_bug_status; $zz = @main::legal_bug_status;
$zz = @main::legal_components;
$zz = @main::legal_opsys; $zz = @main::legal_opsys;
$zz = @main::legal_platform; $zz = @main::legal_platform;
$zz = @main::legal_priority; $zz = @main::legal_priority;
$zz = @main::legal_product;
$zz = @main::legal_severity; $zz = @main::legal_severity;
$zz = @main::legal_target_milestone;
$zz = @main::milestoneurl; $zz = @main::milestoneurl;
$zz = @main::prodmaxvotes; $zz = @main::prodmaxvotes;
} }
...@@ -104,7 +102,7 @@ $::SIG{PIPE} = 'IGNORE'; ...@@ -104,7 +102,7 @@ $::SIG{PIPE} = 'IGNORE';
sub GenerateVersionTable { sub GenerateVersionTable {
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my (@line, %carray); my @line;
SendSQL("SELECT components.name, products.name " . SendSQL("SELECT components.name, products.name " .
"FROM components, products " . "FROM components, products " .
"WHERE products.id = components.product_id " . "WHERE products.id = components.product_id " .
...@@ -116,7 +114,6 @@ sub GenerateVersionTable { ...@@ -116,7 +114,6 @@ sub GenerateVersionTable {
} }
my $ref = $::components{$p}; my $ref = $::components{$p};
push @$ref, $c; push @$ref, $c;
$carray{$c} = 1;
} }
SendSQL("SELECT products.name, classifications.name " . SendSQL("SELECT products.name, classifications.name " .
...@@ -185,8 +182,6 @@ sub GenerateVersionTable { ...@@ -185,8 +182,6 @@ sub GenerateVersionTable {
splice(@::settable_resolution, $z, 1); splice(@::settable_resolution, $z, 1);
} }
@::legal_product = map($_->name, Bugzilla::Product::get_all_products());
require File::Temp; require File::Temp;
my ($fh, $tmpname) = File::Temp::tempfile("versioncache.XXXXX", my ($fh, $tmpname) = File::Temp::tempfile("versioncache.XXXXX",
DIR => "$datadir"); DIR => "$datadir");
...@@ -202,21 +197,19 @@ sub GenerateVersionTable { ...@@ -202,21 +197,19 @@ sub GenerateVersionTable {
print $fh (Data::Dumper->Dump([\@::log_columns], print $fh (Data::Dumper->Dump([\@::log_columns],
['*::log_columns'])); ['*::log_columns']));
foreach my $i (@::legal_product) { my @legal_products = map($_->name, Bugzilla::Product::get_all_products());
foreach my $i (@legal_products) {
if (!defined $::components{$i}) { if (!defined $::components{$i}) {
$::components{$i} = []; $::components{$i} = [];
} }
} }
print $fh (Data::Dumper->Dump([\%::components], print $fh (Data::Dumper->Dump([\%::components],
['*::components'])); ['*::components']));
@::legal_components = sort {uc($a) cmp uc($b)} keys(%carray);
print $fh (Data::Dumper->Dump([\@::legal_components, \@::legal_product, print $fh (Data::Dumper->Dump([\@::legal_priority, \@::legal_severity,
\@::legal_priority, \@::legal_severity,
\@::legal_platform, \@::legal_opsys, \@::legal_platform, \@::legal_opsys,
\@::legal_bug_status, \@::legal_resolution], \@::legal_bug_status, \@::legal_resolution],
['*::legal_components', '*::legal_product', ['*::legal_priority', '*::legal_severity',
'*::legal_priority', '*::legal_severity',
'*::legal_platform', '*::legal_opsys', '*::legal_platform', '*::legal_opsys',
'*::legal_bug_status', '*::legal_resolution'])); '*::legal_bug_status', '*::legal_resolution']));
...@@ -234,25 +227,17 @@ sub GenerateVersionTable { ...@@ -234,25 +227,17 @@ sub GenerateVersionTable {
"WHERE products.id = milestones.product_id " . "WHERE products.id = milestones.product_id " .
"ORDER BY milestones.sortkey, milestones.value"); "ORDER BY milestones.sortkey, milestones.value");
my @line; my @line;
my %tmarray;
@::legal_target_milestone = ();
while(@line = FetchSQLData()) { while(@line = FetchSQLData()) {
my ($tm, $pr) = (@line); my ($tm, $pr) = (@line);
if (!defined $::target_milestone{$pr}) { if (!defined $::target_milestone{$pr}) {
$::target_milestone{$pr} = []; $::target_milestone{$pr} = [];
} }
push @{$::target_milestone{$pr}}, $tm; push @{$::target_milestone{$pr}}, $tm;
if (!exists $tmarray{$tm}) {
$tmarray{$tm} = 1;
push(@::legal_target_milestone, $tm);
}
} }
print $fh (Data::Dumper->Dump([\%::target_milestone, print $fh (Data::Dumper->Dump([\%::target_milestone,
\@::legal_target_milestone,
\%::milestoneurl], \%::milestoneurl],
['*::target_milestone', ['*::target_milestone',
'*::legal_target_milestone',
'*::milestoneurl'])); '*::milestoneurl']));
} }
......
...@@ -44,7 +44,6 @@ sub sillyness { ...@@ -44,7 +44,6 @@ sub sillyness {
$zz = @::legal_opsys; $zz = @::legal_opsys;
$zz = @::legal_platform; $zz = @::legal_platform;
$zz = @::legal_priority; $zz = @::legal_priority;
$zz = @::legal_product;
$zz = @::legal_severity; $zz = @::legal_severity;
$zz = %::target_milestone; $zz = %::target_milestone;
} }
...@@ -219,7 +218,8 @@ if (!Param('letsubmitterchoosepriority')) { ...@@ -219,7 +218,8 @@ if (!Param('letsubmitterchoosepriority')) {
GetVersionTable(); GetVersionTable();
# Some more sanity checking # Some more sanity checking
check_field('product', scalar $cgi->param('product'), \@::legal_product); check_field('product', scalar $cgi->param('product'),
[map($_->name, Bugzilla::Product::get_all_products())]);
check_field('rep_platform', scalar $cgi->param('rep_platform'), \@::legal_platform); check_field('rep_platform', scalar $cgi->param('rep_platform'), \@::legal_platform);
check_field('bug_severity', scalar $cgi->param('bug_severity'), \@::legal_severity); check_field('bug_severity', scalar $cgi->param('bug_severity'), \@::legal_severity);
check_field('priority', scalar $cgi->param('priority'), \@::legal_priority); check_field('priority', scalar $cgi->param('priority'), \@::legal_priority);
......
...@@ -35,21 +35,16 @@ use Bugzilla::Search; ...@@ -35,21 +35,16 @@ use Bugzilla::Search;
use Bugzilla::User; use Bugzilla::User;
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Product; use Bugzilla::Product;
use Bugzilla::Version;
use Bugzilla::Keyword; use Bugzilla::Keyword;
use vars qw( use vars qw(
@legal_resolution @legal_resolution
@legal_bug_status @legal_bug_status
@legal_components
@legal_opsys @legal_opsys
@legal_platform @legal_platform
@legal_priority @legal_priority
@legal_product
@legal_severity @legal_severity
@legal_target_milestone
@log_columns @log_columns
%components
); );
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
...@@ -215,50 +210,26 @@ if ($default{'chfieldto'}->[0] eq "") { ...@@ -215,50 +210,26 @@ if ($default{'chfieldto'}->[0] eq "") {
$default{'chfieldto'} = ["Now"]; $default{'chfieldto'} = ["Now"];
} }
GetVersionTable();
# if using groups for entry, then we don't want people to see products they # if using groups for entry, then we don't want people to see products they
# don't have access to. Remove them from the list. # don't have access to. Remove them from the list.
my @selectable_products = sort {lc($a->name) cmp lc($b->name)} my @selectable_products = sort {lc($a->name) cmp lc($b->name)}
@{$user->get_selectable_products}; @{$user->get_selectable_products};
my %component_set;
my %version_set;
my %milestone_set;
foreach my $prod_obj (@selectable_products) {
# We build up boolean hashes in the "-set" hashes for each of these things
# before making a list because there may be duplicates names across products.
my @component_names = map($_->name, @{$prod_obj->components});
my @version_names = map($_->name, @{$prod_obj->versions});
my @milestone_names = map($_->name, @{$prod_obj->milestones});
$component_set{$_} = 1 foreach (@component_names);
$version_set{$_} = 1 foreach (@version_names);
$milestone_set{$_} = 1 foreach (@milestone_names);
}
# Create the component, version and milestone lists. # Create the component, version and milestone lists.
my @components = (); my %components;
my @versions = (); my %versions;
my @milestones = (); my %milestones;
foreach my $c (@::legal_components) {
if ($component_set{$c}) { foreach my $product (@selectable_products) {
push @components, $c; $components{$_->name} = 1 foreach (@{$product->components});
} $versions{$_->name} = 1 foreach (@{$product->versions});
} $milestones{$_->name} = 1 foreach (@{$product->milestones});
my @all_versions = Bugzilla::Version::distinct_names();
foreach my $v (@all_versions) {
if ($version_set{$v}) {
push @versions, $v;
}
}
foreach my $m (@::legal_target_milestone) {
if ($milestone_set{$m}) {
push @milestones, $m;
}
} }
my @components = sort(keys %components);
my @versions = sort(keys %versions);
my @milestones = sort(keys %milestones);
$vars->{'product'} = \@selectable_products; $vars->{'product'} = \@selectable_products;
# Create data structures representing each classification # Create data structures representing each classification
...@@ -277,6 +248,8 @@ if (Param('usetargetmilestone')) { ...@@ -277,6 +248,8 @@ if (Param('usetargetmilestone')) {
$vars->{'have_keywords'} = Bugzilla::Keyword::keyword_count(); $vars->{'have_keywords'} = Bugzilla::Keyword::keyword_count();
GetVersionTable();
push @::legal_resolution, "---"; # Oy, what a hack. push @::legal_resolution, "---"; # Oy, what a hack.
shift @::legal_resolution; shift @::legal_resolution;
# Another hack - this array contains "" for some reason. See bug 106589. # Another hack - this array contains "" for some reason. See bug 106589.
......
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
var first_load = 1; // is this the first time we load the page? var first_load = 1; // is this the first time we load the page?
var last_sel = []; // caches last selection var last_sel = []; // caches last selection
var cpts = new Array(); var cpts = new Array();
[% FOREACH p = products %] [% FOREACH prod = products %]
cpts['[% p FILTER js %]'] = [ cpts['[% prod.name FILTER js %]'] = [
[%- FOREACH item = components_by_product.$p %]'[% item FILTER js %]'[% ", " UNLESS loop.last %] [%- END -%] ]; [%- FOREACH comp = prod.components %]'[% comp.name FILTER js %]'[% ", " UNLESS loop.last %] [%- END -%] ];
[% END %] [% END %]
[% END %] [% END %]
...@@ -107,18 +107,18 @@ ...@@ -107,18 +107,18 @@
<b>Product/Component:</b><br> <b>Product/Component:</b><br>
<select name="product" onchange="selectProduct(this.form, 'product', 'component', '__Any__');"> <select name="product" onchange="selectProduct(this.form, 'product', 'component', '__Any__');">
<option value="">__Any__</option> <option value="">__Any__</option>
[% FOREACH item = products %] [% FOREACH prod = products %]
<option value="[% item FILTER html %]" <option value="[% prod.name FILTER html %]"
[% "selected" IF type.product.name == item %]> [% "selected" IF type.product.name == prod.name %]>
[% item FILTER html %]</option> [% prod.name FILTER html %]</option>
[% END %] [% END %]
</select><br> </select><br>
<select name="component"> <select name="component">
<option value="">__Any__</option> <option value="">__Any__</option>
[% FOREACH item = components %] [% FOREACH comp = components %]
<option value="[% item FILTER html %]" <option value="[% comp FILTER html %]"
[% "selected" IF type.component.name == item %]> [% "selected" IF type.component.name == comp %]>
[% item FILTER html %]</option> [% comp FILTER html %]</option>
[% END %] [% END %]
</select><br> </select><br>
<input type="submit" name="categoryAction-include" value="Include"> <input type="submit" name="categoryAction-include" value="Include">
......
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