From 8ec8da0491ad89604700b3e29a227966f6d84ba1 Mon Sep 17 00:00:00 2001 From: Perl Tidy Date: Wed, 5 Dec 2018 15:38:52 -0500 Subject: no bug - reformat all the code using the new perltidy rules --- extensions/LastResolved/Config.pm | 6 +- extensions/LastResolved/Extension.pm | 130 +++++++++++++++++------------------ 2 files changed, 67 insertions(+), 69 deletions(-) (limited to 'extensions/LastResolved') diff --git a/extensions/LastResolved/Config.pm b/extensions/LastResolved/Config.pm index 8fd8f106f..c981db7f0 100644 --- a/extensions/LastResolved/Config.pm +++ b/extensions/LastResolved/Config.pm @@ -13,10 +13,8 @@ use warnings; use constant NAME => 'LastResolved'; -use constant REQUIRED_MODULES => [ -]; +use constant REQUIRED_MODULES => []; -use constant OPTIONAL_MODULES => [ -]; +use constant OPTIONAL_MODULES => []; __PACKAGE__->NAME; diff --git a/extensions/LastResolved/Extension.pm b/extensions/LastResolved/Extension.pm index 197bb15d9..798506ae9 100644 --- a/extensions/LastResolved/Extension.pm +++ b/extensions/LastResolved/Extension.pm @@ -22,94 +22,94 @@ use Bugzilla::Install::Util qw(indicate_progress); our $VERSION = '0.01'; sub install_update_db { - my ($self, $args) = @_; - my $last_resolved = Bugzilla::Field->new({'name' => 'cf_last_resolved'}); - if (!$last_resolved) { - Bugzilla::Field->create({ - name => 'cf_last_resolved', - description => 'Last Resolved', - type => FIELD_TYPE_DATETIME, - mailhead => 0, - enter_bug => 0, - obsolete => 0, - custom => 1, - buglist => 1, - }); - _migrate_last_resolved(); - } + my ($self, $args) = @_; + my $last_resolved = Bugzilla::Field->new({'name' => 'cf_last_resolved'}); + if (!$last_resolved) { + Bugzilla::Field->create({ + name => 'cf_last_resolved', + description => 'Last Resolved', + type => FIELD_TYPE_DATETIME, + mailhead => 0, + enter_bug => 0, + obsolete => 0, + custom => 1, + buglist => 1, + }); + _migrate_last_resolved(); + } } sub _migrate_last_resolved { - my $dbh = Bugzilla->dbh; - my $field_id = get_field_id('bug_status'); - my $resolved_activity = $dbh->selectall_arrayref( - "SELECT bugs_activity.bug_id, bugs_activity.bug_when, bugs_activity.who + my $dbh = Bugzilla->dbh; + my $field_id = get_field_id('bug_status'); + my $resolved_activity = $dbh->selectall_arrayref( + "SELECT bugs_activity.bug_id, bugs_activity.bug_when, bugs_activity.who FROM bugs_activity WHERE bugs_activity.fieldid = ? AND bugs_activity.added = 'RESOLVED' - ORDER BY bugs_activity.bug_when", - undef, $field_id); + ORDER BY bugs_activity.bug_when", undef, $field_id + ); - my $count = 1; - my $total = scalar @$resolved_activity; - my %current_last_resolved; - foreach my $activity (@$resolved_activity) { - indicate_progress({ current => $count++, total => $total, every => 25 }); - my ($id, $new, $who) = @$activity; - my $old = $current_last_resolved{$id} ? $current_last_resolved{$id} : ""; - $dbh->do("UPDATE bugs SET cf_last_resolved = ? WHERE bug_id = ?", undef, $new, $id); - LogActivityEntry($id, 'cf_last_resolved', $old, $new, $who, $new); - $current_last_resolved{$id} = $new; - } + my $count = 1; + my $total = scalar @$resolved_activity; + my %current_last_resolved; + foreach my $activity (@$resolved_activity) { + indicate_progress({current => $count++, total => $total, every => 25}); + my ($id, $new, $who) = @$activity; + my $old = $current_last_resolved{$id} ? $current_last_resolved{$id} : ""; + $dbh->do("UPDATE bugs SET cf_last_resolved = ? WHERE bug_id = ?", + undef, $new, $id); + LogActivityEntry($id, 'cf_last_resolved', $old, $new, $who, $new); + $current_last_resolved{$id} = $new; + } } sub bug_check_can_change_field { - my ($self, $args) = @_; - my ($field, $priv_results) = @$args{qw(field priv_results)}; - if ($field eq 'cf_last_resolved') { - push (@$priv_results, PRIVILEGES_REQUIRED_EMPOWERED); - } + my ($self, $args) = @_; + my ($field, $priv_results) = @$args{qw(field priv_results)}; + if ($field eq 'cf_last_resolved') { + push(@$priv_results, PRIVILEGES_REQUIRED_EMPOWERED); + } } sub bug_end_of_update { - my ($self, $args) = @_; - my $dbh = Bugzilla->dbh; - my ($bug, $old_bug, $timestamp, $changes) = - @$args{qw(bug old_bug timestamp changes)}; - if ($changes->{'bug_status'}) { - # If the bug has been resolved then update the cf_last_resolved - # value to the current timestamp if cf_last_resolved exists - if ($bug->bug_status eq 'RESOLVED') { - $dbh->do("UPDATE bugs SET cf_last_resolved = ? WHERE bug_id = ?", - undef, $timestamp, $bug->id); - my $old_value = $bug->cf_last_resolved || ''; - LogActivityEntry($bug->id, 'cf_last_resolved', $old_value, - $timestamp, Bugzilla->user->id, $timestamp); - } + my ($self, $args) = @_; + my $dbh = Bugzilla->dbh; + my ($bug, $old_bug, $timestamp, $changes) + = @$args{qw(bug old_bug timestamp changes)}; + if ($changes->{'bug_status'}) { + + # If the bug has been resolved then update the cf_last_resolved + # value to the current timestamp if cf_last_resolved exists + if ($bug->bug_status eq 'RESOLVED') { + $dbh->do("UPDATE bugs SET cf_last_resolved = ? WHERE bug_id = ?", + undef, $timestamp, $bug->id); + my $old_value = $bug->cf_last_resolved || ''; + LogActivityEntry($bug->id, 'cf_last_resolved', $old_value, $timestamp, + Bugzilla->user->id, $timestamp); } + } } sub bug_fields { - my ($self, $args) = @_; - my $fields = $args->{'fields'}; - push (@$fields, 'cf_last_resolved') + my ($self, $args) = @_; + my $fields = $args->{'fields'}; + push(@$fields, 'cf_last_resolved'); } sub object_columns { - my ($self, $args) = @_; - my ($class, $columns) = @$args{qw(class columns)}; - if ($class->isa('Bugzilla::Bug')) { - push(@$columns, 'cf_last_resolved'); - } + my ($self, $args) = @_; + my ($class, $columns) = @$args{qw(class columns)}; + if ($class->isa('Bugzilla::Bug')) { + push(@$columns, 'cf_last_resolved'); + } } sub buglist_columns { - my ($self, $args) = @_; - my $columns = $args->{columns}; - $columns->{'cf_last_resolved'} = { - name => 'bugs.cf_last_resolved', - title => 'Last Resolved', - }; + my ($self, $args) = @_; + my $columns = $args->{columns}; + $columns->{'cf_last_resolved'} + = {name => 'bugs.cf_last_resolved', title => 'Last Resolved',}; } __PACKAGE__->NAME; -- cgit v1.2.3-24-g4f1b