]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 495783: Create the default Classification before setting up foreign keys, so...
authormkanat%bugzilla.org <>
Tue, 2 Jun 2009 00:10:04 +0000 (00:10 +0000)
committermkanat%bugzilla.org <>
Tue, 2 Jun 2009 00:10:04 +0000 (00:10 +0000)
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat

Bugzilla/Install.pm
Bugzilla/Install/DB.pm
checksetup.pl

index 65e19412cc981ca5b1dff961b28bb21aeecd0748..c469aa857c2792c459143673c5997ad2c5260607 100644 (file)
@@ -217,15 +217,20 @@ sub update_system_groups {
 
 }
 
-# This function should be called only after creating the admin user.
-sub create_default_product {
+sub create_default_classification {
     my $dbh = Bugzilla->dbh;
+
     # Make the default Classification if it doesn't already exist.
     if (!$dbh->selectrow_array('SELECT 1 FROM classifications')) {
-        print get_text('install_default_classification', 
+        print get_text('install_default_classification',
                        { name => DEFAULT_CLASSIFICATION->{name} }) . "\n";
         Bugzilla::Classification->create(DEFAULT_CLASSIFICATION);
     }
+}
+
+# This function should be called only after creating the admin user.
+sub create_default_product {
+    my $dbh = Bugzilla->dbh;
 
     # And same for the default product/component.
     if (!$dbh->selectrow_array('SELECT 1 FROM products')) {
@@ -426,9 +431,14 @@ Params:      none
 
 Returns:     nothing.
 
+=item C<create_default_classification>
+
+Creates the default "Unclassified" L<Classification|Bugzilla::Classification>
+if it doesn't already exist
+
 =item C<create_default_product()>
 
-Description: Creates the default product and classification if
+Description: Creates the default product and component if
              they don't exist.
 
 Params:      none
index 0c918165536fbf2a2556ca9bb39e06a8e991c301..53f800b82f29b1969920e0acb81e23bbcebe7186 100644 (file)
@@ -24,6 +24,7 @@ use strict;
 
 use Bugzilla::Constants;
 use Bugzilla::Hook;
+use Bugzilla::Install ();
 use Bugzilla::Install::Util qw(indicate_progress install_string);
 use Bugzilla::Util;
 use Bugzilla::Series;
@@ -578,6 +579,13 @@ sub update_table_definitions {
 
     Bugzilla::Hook::process('install-update_db');
 
+    # We do this here because otherwise the foreign key from 
+    # products.classification_id to classifications.id will fail
+    # (because products.classification_id defaults to "1", so on upgraded
+    # installations it's already been set before the first Classification
+    # exists).
+    Bugzilla::Install::create_default_classification();
+
     $dbh->bz_setup_foreign_keys();
 }
 
index 53a709ebf37ba9a0c8fb9a0738318fc3b46929e9..0f410ed7de3e2ebf98c2e92006cad75d999ca30d 100755 (executable)
@@ -217,7 +217,7 @@ Bugzilla::Install::reset_password($switch{'reset-password'})
     if $switch{'reset-password'};
 
 ###########################################################################
-# Create default Product and Classification
+# Create default Product
 ###########################################################################
 
 Bugzilla::Install::create_default_product();
@@ -406,6 +406,10 @@ from one version of Bugzilla to another.
 
 The code for this is in L<Bugzilla::Install::DB/update_table_definitions>.
 
+This includes creating the default Classification (using 
+L<Bugzilla::Install/create_default_classification>) and setting up all
+the foreign keys for all tables, using L<Bugzilla::DB/bz_setup_foreign_keys>.
+
 =item 14
 
 Creates the system groups--the ones like C<editbugs>, C<admin>, and so on.
@@ -426,7 +430,7 @@ the C<--make-admin> switch.
 
 =item 17
 
-Creates the default Classification, Product, and Component, using
+Creates the default Product and Component, using
 L<Bugzilla::Install/create_default_product>.
 
 =back