]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 328203: Cannot update a product if 'usetargetmilestone' is off (and the default...
authorlpsolit%gmail.com <>
Wed, 1 Mar 2006 06:09:46 +0000 (06:09 +0000)
committerlpsolit%gmail.com <>
Wed, 1 Mar 2006 06:09:46 +0000 (06:09 +0000)
editproducts.cgi

index 2b7c5dc5d5b204b9571336bdefcb7bc54d68c4bf..d7a5fcd455e30e9f64ac09fc705627015920a9ff 100755 (executable)
@@ -23,7 +23,7 @@
 #               Dawn Endico <endico@mozilla.org>
 #               Joe Robins <jmrobins@tgix.com>
 #               Gavin Shelley <bugzilla@chimpychompy.org>
-#               Fr��ic Buclin <LpSolit@gmail.com>
+#               Frédéric Buclin <LpSolit@gmail.com>
 #               Greg Hendricks <ghendricks@novell.com>
 #               Lance Larsh <lance.larsh@oracle.com>
 #
@@ -818,13 +818,28 @@ if ($action eq 'update') {
                        {product => $product_name});
     }
 
-    my $milestone = new Bugzilla::Milestone($product_old->id,
-                                            $defaultmilestone);
-    if (!$milestone) {
-        ThrowUserError('prod_must_define_defaultmilestone',
-                       {product          => $product_old->name,
-                        defaultmilestone => $defaultmilestone,
-                        classification   => $classification_name});
+    # Only update milestone related stuff if 'usetargetmilestone' is on.
+    if (Param('usetargetmilestone')) {
+        my $milestone = new Bugzilla::Milestone($product_old->id,
+                                                $defaultmilestone);
+
+        unless ($milestone) {
+            ThrowUserError('prod_must_define_defaultmilestone',
+                           {product          => $product_old->name,
+                            defaultmilestone => $defaultmilestone,
+                            classification   => $classification_name});
+        }
+
+        if ($milestoneurl ne $product_old->milestone_url) {
+            trick_taint($milestoneurl);
+            $dbh->do('UPDATE products SET milestoneurl = ? WHERE id = ?',
+                     undef, ($milestoneurl, $product_old->id));
+        }
+
+        if ($milestone->name ne $product_old->default_milestone) {
+            $dbh->do('UPDATE products SET defaultmilestone = ? WHERE id = ?',
+                     undef, ($milestone->name, $product_old->id));
+        }
     }
 
     $disallownew = $disallownew ? 1 : 0;
@@ -839,13 +854,6 @@ if ($action eq 'update') {
                  undef, ($description, $product_old->id));
     }
 
-    if (Param('usetargetmilestone')
-        && ($milestoneurl ne $product_old->milestone_url)) {
-        trick_taint($milestoneurl);
-        $dbh->do('UPDATE products SET milestoneurl = ? WHERE id = ?',
-                 undef, ($milestoneurl, $product_old->id));
-    }
-
     if ($votesperuser ne $product_old->votes_per_user) {
         $dbh->do('UPDATE products SET votesperuser = ? WHERE id = ?',
                  undef, ($votesperuser, $product_old->id));
@@ -864,12 +872,6 @@ if ($action eq 'update') {
         $checkvotes = 1;
     }
 
-    if ($defaultmilestone ne $product_old->default_milestone) {
-        trick_taint($defaultmilestone);
-        $dbh->do('UPDATE products SET defaultmilestone = ? WHERE id = ?',
-                 undef, ($defaultmilestone, $product_old->id));
-    }
-
     if ($product_name ne $product_old->name) {
         trick_taint($product_name);
         $dbh->do('UPDATE products SET name = ? WHERE id = ?',