Bug 69481 - Log activity when renaming versions/milestones
git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@1075 6955db30-a419-402b-8a0d-67ecbb4d7f56master
parent
ed886d23d9
commit
89349ea168
|
@ -160,6 +160,8 @@ sub run_create_validators
|
||||||
sub update
|
sub update
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
# Bugzilla::Field::Choice is not a threat as we don't have 'value' field
|
||||||
|
# Yet do not call its update() for the future
|
||||||
my $changes = Bugzilla::Object::update($self, @_);
|
my $changes = Bugzilla::Object::update($self, @_);
|
||||||
|
|
||||||
# Fill visibility values
|
# Fill visibility values
|
||||||
|
|
|
@ -120,21 +120,50 @@ sub create
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub update
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
my $dbh = Bugzilla->dbh;
|
||||||
|
$dbh->bz_start_transaction();
|
||||||
|
|
||||||
|
# Not Bugzilla::Field::Choice! It will overwrite other products' bug values
|
||||||
|
my ($changes, $old_self) = Bugzilla::Object::update($self, @_);
|
||||||
|
|
||||||
|
if (exists $changes->{value})
|
||||||
|
{
|
||||||
|
# Record activity
|
||||||
|
$dbh->do(
|
||||||
|
'INSERT INTO bugs_activity (bug_id, who, bug_when, fieldid, added, removed)'.
|
||||||
|
' SELECT bug_id, ?, NOW(), ?, ?, ? FROM bugs WHERE target_milestone = ? AND product_id = ?', undef,
|
||||||
|
Bugzilla->user->id, $self->field->id, $self->name, $changes->{value}->[0], $changes->{value}->[0], $self->product_id
|
||||||
|
);
|
||||||
|
# The milestone value is stored in the bugs table instead of its ID.
|
||||||
|
$dbh->do(
|
||||||
|
'UPDATE bugs SET target_milestone = ? WHERE target_milestone = ? AND product_id = ?',
|
||||||
|
undef, $self->name, $changes->{value}->[0], $self->product_id
|
||||||
|
);
|
||||||
|
# The default milestone also stores the value instead of the ID.
|
||||||
|
$dbh->do(
|
||||||
|
'UPDATE products SET defaultmilestone = ? WHERE id = ? AND defaultmilestone = ?',
|
||||||
|
undef, $self->name, $self->product_id, $changes->{value}->[0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Fill visibility values
|
||||||
|
$self->set_visibility_values([ $self->product_id ]);
|
||||||
|
$dbh->bz_commit_transaction();
|
||||||
|
|
||||||
|
return $changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub update {
|
sub update {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $changes = Bugzilla::Object::update($self, @_);
|
my $changes = Bugzilla::Object::update($self, @_);
|
||||||
|
|
||||||
if (exists $changes->{value}) {
|
if (exists $changes->{value}) {
|
||||||
my $dbh = Bugzilla->dbh;
|
my $dbh = Bugzilla->dbh;
|
||||||
# The milestone value is stored in the bugs table instead of its ID.
|
|
||||||
$dbh->do('UPDATE bugs SET target_milestone = ?
|
|
||||||
WHERE target_milestone = ? AND product_id = ?',
|
|
||||||
undef, ($self->name, $changes->{value}->[0], $self->product_id));
|
|
||||||
|
|
||||||
# The default milestone also stores the value instead of the ID.
|
|
||||||
$dbh->do('UPDATE products SET defaultmilestone = ?
|
|
||||||
WHERE id = ? AND defaultmilestone = ?',
|
|
||||||
undef, ($self->name, $self->product_id, $changes->{value}->[0]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Fill visibility values
|
# Fill visibility values
|
||||||
|
|
|
@ -181,7 +181,9 @@ sub update {
|
||||||
|
|
||||||
# Don't update the DB if something goes wrong below -> transaction.
|
# Don't update the DB if something goes wrong below -> transaction.
|
||||||
$dbh->bz_start_transaction();
|
$dbh->bz_start_transaction();
|
||||||
my ($changes, $old_self) = $self->SUPER::update(@_);
|
# Bugzilla::Field::Choice is not a threat as we don't have 'value' field
|
||||||
|
# Yet do not call its update() for the future
|
||||||
|
my ($changes, $old_self) = Bugzilla::Object::update(@_);
|
||||||
|
|
||||||
# We also have to fix votes.
|
# We also have to fix votes.
|
||||||
my @msgs; # Will store emails to send to voters.
|
my @msgs; # Will store emails to send to voters.
|
||||||
|
|
|
@ -144,17 +144,31 @@ sub create
|
||||||
sub update
|
sub update
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
my $dbh = Bugzilla->dbh;
|
||||||
|
$dbh->bz_start_transaction();
|
||||||
|
|
||||||
|
# Not Bugzilla::Field::Choice! It will overwrite other products' bug values
|
||||||
my ($changes, $old_self) = Bugzilla::Object::update($self, @_);
|
my ($changes, $old_self) = Bugzilla::Object::update($self, @_);
|
||||||
|
|
||||||
if (exists $changes->{value}) {
|
if (exists $changes->{value})
|
||||||
my $dbh = Bugzilla->dbh;
|
{
|
||||||
$dbh->do('UPDATE bugs SET version = ?
|
# Record activity
|
||||||
WHERE version = ? AND product_id = ?',
|
$dbh->do(
|
||||||
undef, ($self->name, $old_self->name, $self->product_id));
|
'INSERT INTO bugs_activity (bug_id, who, bug_when, fieldid, added, removed)'.
|
||||||
|
' SELECT bug_id, ?, NOW(), ?, ?, ? FROM bugs WHERE version = ? AND product_id = ?', undef,
|
||||||
|
Bugzilla->user->id, $self->field->id, $self->name, $old_self->name, $old_self->name, $self->product_id
|
||||||
|
);
|
||||||
|
# Rename version
|
||||||
|
$dbh->do(
|
||||||
|
'UPDATE bugs SET version = ? WHERE version = ? AND product_id = ?',
|
||||||
|
undef, $self->name, $old_self->name, $self->product_id
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Fill visibility values
|
# Fill visibility values
|
||||||
$self->set_visibility_values([ $self->product_id ]);
|
$self->set_visibility_values([ $self->product_id ]);
|
||||||
|
$dbh->bz_commit_transaction();
|
||||||
|
|
||||||
return $changes;
|
return $changes;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue