From e39a1db4115cfd721fa65c746e7699e79cda87ae Mon Sep 17 00:00:00 2001 From: "ghendricks%novell.com" <> Date: Wed, 20 May 2009 23:09:55 +0000 Subject: Bug 493090 - Product disallownew should be converted to isactive patch by ghendricks r=mkanat a=mkanat --- Bugzilla/DB/Schema.pm | 4 ++-- Bugzilla/Install/DB.pm | 29 +++++++++++++++++++++++++---- Bugzilla/Product.pm | 12 ++++++------ Bugzilla/User.pm | 2 +- 4 files changed, 34 insertions(+), 13 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index aacbe386b..f31a312cf 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -1176,8 +1176,8 @@ use constant ABSTRACT_SCHEMA => { description => {TYPE => 'MEDIUMTEXT'}, milestoneurl => {TYPE => 'TINYTEXT', NOTNULL => 1, DEFAULT => "''"}, - disallownew => {TYPE => 'BOOLEAN', NOTNULL => 1, - DEFAULT => 0}, + isactive => {TYPE => 'BOOLEAN', NOTNULL => 1, + DEFAULT => 1}, votesperuser => {TYPE => 'INT2', NOTNULL => 1, DEFAULT => 0}, maxvotesperbug => {TYPE => 'INT2', NOTNULL => 1, diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 2247e58b3..0c9181655 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -459,8 +459,10 @@ sub update_table_definitions { # The products table lacked sensible defaults. $dbh->bz_alter_column('products', 'milestoneurl', {TYPE => 'TINYTEXT', NOTNULL => 1, DEFAULT => "''"}); - $dbh->bz_alter_column('products', 'disallownew', - {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 0}); + if ($dbh->bz_column_info('products', 'disallownew')){ + $dbh->bz_alter_column('products', 'disallownew', + {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 0}); + } $dbh->bz_alter_column('products', 'votesperuser', {TYPE => 'INT2', NOTNULL => 1, DEFAULT => 0}); $dbh->bz_alter_column('products', 'votestoconfirm', @@ -567,6 +569,8 @@ sub update_table_definitions { # 2009-01-16 oreomike@gmail.com - Bug 302420 $dbh->bz_add_column('whine_events', 'mailifnobugs', { TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'}); + + _convert_disallownew_to_isactive(); ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # @@ -591,8 +595,11 @@ sub _update_pre_checksetup_bugzillas { $dbh->bz_add_column('bugs', 'qa_contact', {TYPE => 'INT3'}); $dbh->bz_add_column('bugs', 'status_whiteboard', {TYPE => 'MEDIUMTEXT', NOTNULL => 1, DEFAULT => "''"}); - $dbh->bz_add_column('products', 'disallownew', - {TYPE => 'BOOLEAN', NOTNULL => 1}, 0); + if (!$dbh->bz_column_info('products', 'isactive')){ + $dbh->bz_add_column('products', 'disallownew', + {TYPE => 'BOOLEAN', NOTNULL => 1}, 0); + } + $dbh->bz_add_column('products', 'milestoneurl', {TYPE => 'TINYTEXT', NOTNULL => 1}, ''); $dbh->bz_add_column('components', 'initialqacontact', @@ -3149,6 +3156,20 @@ sub _add_visiblity_value_to_value_tables { } } +sub _convert_disallownew_to_isactive { + my $dbh = Bugzilla->dbh; + if ($dbh->bz_column_info('products', 'disallownew')){ + $dbh->bz_add_column('products', 'isactive', + { TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE'}); + + # isactive is the boolean reverse of disallownew. + $dbh->do('UPDATE products SET isactive = 0 WHERE disallownew = 1'); + $dbh->do('UPDATE products SET isactive = 1 WHERE disallownew = 0'); + + $dbh->bz_drop_column('products','disallownew'); + } +} + 1; __END__ diff --git a/Bugzilla/Product.pm b/Bugzilla/Product.pm index 488624c43..4d0082006 100644 --- a/Bugzilla/Product.pm +++ b/Bugzilla/Product.pm @@ -53,7 +53,7 @@ use constant DB_COLUMNS => qw( classification_id description milestoneurl - disallownew + isactive votesperuser maxvotesperbug votestoconfirm @@ -71,7 +71,7 @@ use constant UPDATE_COLUMNS => qw( description defaultmilestone milestoneurl - disallownew + isactive votesperuser maxvotesperbug votestoconfirm @@ -84,7 +84,7 @@ use constant VALIDATORS => { version => \&_check_version, defaultmilestone => \&_check_default_milestone, milestoneurl => \&_check_milestone_url, - disallownew => \&Bugzilla::Object::check_boolean, + isactive => \&Bugzilla::Object::check_boolean, votesperuser => \&_check_votes_per_user, maxvotesperbug => \&_check_votes_per_bug, votestoconfirm => \&_check_votes_to_confirm, @@ -601,7 +601,7 @@ sub set_name { $_[0]->set('name', $_[1]); } sub set_description { $_[0]->set('description', $_[1]); } sub set_default_milestone { $_[0]->set('defaultmilestone', $_[1]); } sub set_milestone_url { $_[0]->set('milestoneurl', $_[1]); } -sub set_disallow_new { $_[0]->set('disallownew', $_[1]); } +sub set_is_active { $_[0]->set('isactive', $_[1]); } sub set_votes_per_user { $_[0]->set('votesperuser', $_[1]); } sub set_votes_per_bug { $_[0]->set('maxvotesperbug', $_[1]); } sub set_votes_to_confirm { $_[0]->set('votestoconfirm', $_[1]); } @@ -858,7 +858,7 @@ sub flag_types { sub description { return $_[0]->{'description'}; } sub milestone_url { return $_[0]->{'milestoneurl'}; } -sub disallow_new { return $_[0]->{'disallownew'}; } +sub is_active { return $_[0]->{'isactive'}; } sub votes_per_user { return $_[0]->{'votesperuser'}; } sub max_votes_per_bug { return $_[0]->{'maxvotesperbug'}; } sub votes_to_confirm { return $_[0]->{'votestoconfirm'}; } @@ -911,7 +911,7 @@ Bugzilla::Product - Bugzilla product class. my $name = $product->name; my $description = $product->description; my $milestoneurl = $product->milestone_url; - my disallownew = $product->disallow_new; + my isactive = $product->is_active; my votesperuser = $product->votes_per_user; my maxvotesperbug = $product->max_votes_per_bug; my votestoconfirm = $product->votes_to_confirm; diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 661d2f167..bc142636e 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -759,7 +759,7 @@ sub get_enterable_products { AND group_control_map.entry != 0 AND group_id NOT IN (' . $self->groups_as_string . ') WHERE group_id IS NULL - AND products.disallownew = 0') || []}; + AND products.isactive = 1') || []}; if (@enterable_ids) { # And all of these products must have at least one component -- cgit v1.2.3-24-g4f1b