From 045e964867ae036ddc7d5b41a03dd48d8f291ee7 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Sun, 20 Aug 2006 03:56:50 +0000 Subject: Bug 346241: Make series.creator nullable in the DB and use NULL for series with creator 0 - Patch by RĂ©mi Zara r=wicked a=myk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla/DB/Schema.pm | 2 +- Bugzilla/Install/DB.pm | 13 ++++++++++--- Bugzilla/Series.pm | 9 +++------ 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index 1888c76c0..a26eb311b 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -915,7 +915,7 @@ use constant ABSTRACT_SCHEMA => { FIELDS => [ series_id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1}, - creator => {TYPE => 'INT3', NOTNULL => 1}, + creator => {TYPE => 'INT3'}, category => {TYPE => 'INT2', NOTNULL => 1}, subcategory => {TYPE => 'INT2', NOTNULL => 1}, name => {TYPE => 'varchar(64)', NOTNULL => 1}, diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index d34a11f24..a7f20625a 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -277,6 +277,14 @@ sub update_table_definitions { _remove_spaces_and_commas_from_flagtypes(); _setup_usebuggroups_backward_compatibility(); _remove_user_series_map(); + + # 2006-08-03 remi_zara@mac.com bug 346241, make series.creator nullable + # This must happen before calling _copy_old_charts_into_database(). + if ($dbh->bz_column_info('series', 'creator')->{NOTNULL}) { + $dbh->bz_alter_column('series', 'creator', {TYPE => 'INT3'}); + $dbh->do("UPDATE series SET creator = NULL WHERE creator = 0"); + } + _copy_old_charts_into_database(); _add_user_group_map_grant_type(); @@ -1877,9 +1885,8 @@ sub _copy_old_charts_into_database { foreach my $field (@fields) { # Create a Series for each field in this product. - # user ID = 0 is used. my $series = new Bugzilla::Series(undef, $product, $all_name, - $field, 0, 1, + $field, undef, 1, $queries{$field}, 1); $series->writeToDatabase(); $seriesids{$field} = $series->{'series_id'}; @@ -1890,7 +1897,7 @@ sub _copy_old_charts_into_database { my @openedstatuses = ("UNCONFIRMED", "NEW", "ASSIGNED", "REOPENED"); my $query = join("&", map { "bug_status=$_" } @openedstatuses); my $series = new Bugzilla::Series(undef, $product, $all_name, - $open_name, 0, 1, + $open_name, undef, 1, $query_prod . $query, 1); $series->writeToDatabase(); $seriesids{$open_name} = $series->{'series_id'}; diff --git a/Bugzilla/Series.pm b/Bugzilla/Series.pm index 4693a7131..011e60168 100644 --- a/Bugzilla/Series.pm +++ b/Bugzilla/Series.pm @@ -36,8 +36,6 @@ use Bugzilla::Error; use Bugzilla::Util; use Bugzilla::User; -use constant PUBLIC_USER_ID => 0; - sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; @@ -201,10 +199,9 @@ sub writeToDatabase { # Insert the new series into the series table $dbh->do("INSERT INTO series (creator, category, subcategory, " . "name, frequency, query, is_public) VALUES " . - "($self->{'creator'}, " . - "$category_id, $subcategory_id, " . - $dbh->quote($self->{'name'}) . ", $self->{'frequency'}," . - $dbh->quote($self->{'query'}) . ", $self->{'public'})"); + "(?, ?, ?, ?, ?, ?, ?)", undef, + $self->{'creator'}, $category_id, $subcategory_id, $self->{'name'}, + $self->{'frequency'}, $self->{'query'}, $self->{'public'}); # Retrieve series_id $self->{'series_id'} = $dbh->selectrow_array("SELECT MAX(series_id) " . -- cgit v1.2.3-24-g4f1b