Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
e068bcc7
Commit
e068bcc7
authored
Dec 18, 2012
by
Dave Lawrence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 813628 - New extension hook for Bugzilla::Bug::update called bug_start_of_update
r/a=LpSolit
parent
64e21e0b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
0 deletions
+73
-0
Bug.pm
Bugzilla/Bug.pm
+4
-0
Hook.pm
Bugzilla/Hook.pm
+33
-0
Extension.pm
extensions/Example/Extension.pm
+36
-0
No files found.
Bugzilla/Bug.pm
View file @
e068bcc7
...
...
@@ -791,6 +791,10 @@ sub update {
my
(
$changes
,
$old_bug
)
=
$self
->
SUPER::
update
(
@_
);
Bugzilla::Hook::
process
(
'bug_start_of_update'
,
{
timestamp
=>
$delta_ts
,
bug
=>
$self
,
old_bug
=>
$old_bug
,
changes
=>
$changes
});
# Certain items in $changes have to be fixed so that they hold
# a name instead of an ID.
foreach
my
$field
(
qw(product_id component_id)
)
{
...
...
Bugzilla/Hook.pm
View file @
e068bcc7
...
...
@@ -421,6 +421,39 @@ to the user.
=back
=head2 bug_start_of_update
This happens near the beginning of L<Bugzilla::Bug/update>, after L<Bugzilla::Object/update>
is called, but before all other special changes are made to the database. Once use case is
this allows for adding your own entries to the C<changes> hash which gets added to the
bugs_activity table later keeping you from having to do it yourself. Also this is also helpful
if your extension needs to add CC members, flags, keywords, groups, etc. This generally
occurs inside a database transaction.
Params:
=over
=item C<bug>
The changed bug object, with all fields set to their updated values.
=item C<old_bug>
A bug object pulled from the database before the fields were set to
their updated values (so it has the old values available for each field).
=item C<timestamp>
The timestamp used for all updates in this transaction, as a SQL date
string.
=item C<changes>
The hash of changed fields. C<< $changes->{field} = [old, new] >>
=back
=head2 bug_url_sub_classes
Allows you to add more L<Bugzilla::BugUrl> sub-classes.
...
...
extensions/Example/Extension.pm
View file @
e068bcc7
...
...
@@ -153,6 +153,42 @@ sub bug_end_of_create_validators {
# $bug_params->{cc} = [];
}
sub
bug_start_of_update
{
my
(
$self
,
$args
)
=
@_
;
# This code doesn't actually *do* anything, it's just here to show you
# how to use this hook.
my
(
$bug
,
$old_bug
,
$timestamp
,
$changes
)
=
@$args
{
qw(bug old_bug timestamp changes)
};
foreach
my
$field
(
keys
%
$changes
)
{
my
$used_to_be
=
$changes
->
{
$field
}
->
[
0
];
my
$now_it_is
=
$changes
->
{
$field
}
->
[
1
];
}
my
$old_summary
=
$old_bug
->
short_desc
;
my
$status_message
;
if
(
my
$status_change
=
$changes
->
{
'bug_status'
})
{
my
$old_status
=
new
Bugzilla::
Status
({
name
=>
$status_change
->
[
0
]
});
my
$new_status
=
new
Bugzilla::
Status
({
name
=>
$status_change
->
[
1
]
});
if
(
$new_status
->
is_open
&&
!
$old_status
->
is_open
)
{
$status_message
=
"Bug re-opened!"
;
}
if
(
!
$new_status
->
is_open
&&
$old_status
->
is_open
)
{
$status_message
=
"Bug closed!"
;
}
}
my
$bug_id
=
$bug
->
id
;
my
$num_changes
=
scalar
keys
%
$changes
;
my
$result
=
"There were $num_changes changes to fields on bug $bug_id"
.
" at $timestamp."
;
# Uncomment this line to see $result in your webserver's error log whenever
# you update a bug.
# warn $result;
}
sub
bug_end_of_update
{
my
(
$self
,
$args
)
=
@_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment