summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/Hook.pm24
-rw-r--r--Bugzilla/Object.pm7
-rw-r--r--extensions/Example/Extension.pm9
3 files changed, 37 insertions, 3 deletions
diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm
index 789ad8740..adcb7ff4b 100644
--- a/Bugzilla/Hook.pm
+++ b/Bugzilla/Hook.pm
@@ -210,8 +210,7 @@ Params:
=over
-=item C<bug> - The changed bug object, with all fields set to their updated
-values.
+=item C<bug> - The created bug object.
=item C<timestamp> - The timestamp used for all updates in this transaction,
as a SQL date string.
@@ -821,6 +820,27 @@ or remove standard object columns using this hook.
=back
+=head2 object_end_of_create
+
+Called at the end of L<Bugzilla::Object/create>, after all other changes are
+made to the database. This occurs inside a database transaction.
+
+Params:
+
+=over
+
+=item C<class>
+
+The name of the class that C<create> was called on. You can check this
+like C<< if ($class->isa('Some::Class')) >> in your code, to perform specific
+tasks for only certain classes.
+
+=item C<object>
+
+The created object.
+
+=back
+
=head2 object_end_of_create_validators
Called at the end of L<Bugzilla::Object/run_create_validators>. You can
diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm
index 66dac9422..5b8576512 100644
--- a/Bugzilla/Object.pm
+++ b/Bugzilla/Object.pm
@@ -508,7 +508,12 @@ sub insert_create_data {
$dbh->do("INSERT INTO $table (" . join(', ', @field_names)
. ") VALUES ($qmarks)", undef, @values);
my $id = $dbh->bz_last_key($table, $class->ID_FIELD);
- return $class->new($id);
+
+ my $object = $class->new($id);
+
+ Bugzilla::Hook::process('object_end_of_create', { class => $class,
+ object => $object });
+ return $object;
}
sub get_all {
diff --git a/extensions/Example/Extension.pm b/extensions/Example/Extension.pm
index 4d85d01f8..5c6865362 100644
--- a/extensions/Example/Extension.pm
+++ b/extensions/Example/Extension.pm
@@ -408,6 +408,15 @@ sub object_columns {
}
}
+sub object_end_of_create {
+ my ($self, $args) = @_;
+
+ my $class = $args->{'class'};
+ my $object = $args->{'object'};
+
+ warn "Created a new $class object!";
+}
+
sub object_end_of_create_validators {
my ($self, $args) = @_;