3
# The contents of this file are subject to the Mozilla Public
4
# License Version 1.1 (the "License"); you may not use this file
5
# except in compliance with the License. You may obtain a copy of
6
# the License at http://www.mozilla.org/MPL/
8
# Software distributed under the License is distributed on an "AS
9
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
# implied. See the License for the specific language governing
11
# rights and limitations under the License.
13
# The Original Code is the Bugzilla Bug Tracking System.
15
# The Initial Developer of the Original Code is Everything Solved, Inc.
16
# Portions created by the Initial Developer are Copyright (C) 2009 the
17
# Initial Developer. All Rights Reserved.
20
# Max Kanat-Alexander <mkanat@bugzilla.org>
27
use Bugzilla::Config qw(:admin);
30
my $confirmed = new Bugzilla::Status({ name => 'CONFIRMED' });
31
my $in_progress = new Bugzilla::Status({ name => 'IN_PROGRESS' });
33
if ($confirmed and $in_progress) {
34
print "You are already using the new workflow.\n";
39
WARNING: This will convert the status of all bugs using the following
42
"NEW" will become "CONFIRMED"
43
"ASSIGNED" will become "IN_PROGRESS"
44
"REOPENED" will become "CONFIRMED" (and the "REOPENED" status will be removed)
45
"CLOSED" will become "VERIFIED" (and the "CLOSED" status will be removed)
47
This change will be immediate. The history of each bug will also be changed
48
so that it appears that these statuses were always in existence.
50
Emails will not be sent for the change.
52
To continue, press any key, or press Ctrl-C to stop this program...
56
my $dbh = Bugzilla->dbh;
59
ASSIGNED => 'IN_PROGRESS',
60
REOPENED => 'CONFIRMED',
64
my $status_field = Bugzilla::Field->check('bug_status');
65
$dbh->bz_start_transaction();
66
while (my ($from, $to) = each %translation) {
67
print "Converting $from to $to...\n";
68
$dbh->do('UPDATE bugs SET bug_status = ? WHERE bug_status = ?',
71
if (Bugzilla->params->{'duplicate_or_move_bug_status'} eq $from) {
72
SetParam('duplicate_or_move_bug_status', $to);
76
foreach my $what (qw(added removed)) {
77
$dbh->do("UPDATE bugs_activity SET $what = ?
78
WHERE fieldid = ? AND $what = ?",
79
undef, $to, $status_field->id, $from);
82
# Delete any transitions where it now appears that
83
# a bug moved from a status to itself.
84
$dbh->do('DELETE FROM bugs_activity WHERE fieldid = ? AND added = removed',
85
undef, $status_field->id);
87
# If the new status already exists, just delete the old one, but retain
88
# the workflow items from it.
89
if (my $existing = new Bugzilla::Status({ name => $to })) {
90
$dbh->do('DELETE FROM bug_status WHERE value = ?', undef, $from);
92
# Otherwise, rename the old status to the new one.
94
$dbh->do('UPDATE bug_status SET value = ? WHERE value = ?',
99
$dbh->bz_commit_transaction();
102
Done. There are some things you may want to fix, now:
104
* You may want to run ./collectstats.pl --regenerate to regenerate
105
data for the Old Charts system.
106
* You may have to fix the Status Workflow using the Status Workflow
107
panel in "Administration".
108
* You will probably want to update the "mybugstemplate" and "defaultquery"
109
parameters using the Parameters panel in "Administration". (Just
110
resetting them to the default will work.)