From 5fc80f94271780b6ff6d1dbba554df35e803ac51 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Tue, 24 Nov 2009 06:09:41 +0000 Subject: Bug 430014: Re-write the code hooks system so that it uses modules instead of individual .pl files Patch by Max Kanat-Alexander (module owner) a=mkanat --- Bugzilla/Attachment.pm | 2 +- Bugzilla/Auth/Login/Stack.pm | 2 +- Bugzilla/Auth/Verify/Stack.pm | 2 +- Bugzilla/Bug.pm | 10 +- Bugzilla/Config.pm | 4 +- Bugzilla/DB/Schema.pm | 2 +- Bugzilla/Error.pm | 2 +- Bugzilla/Extension.pm | 364 +++++++++++++++++++++++++++++++++++++++ Bugzilla/Flag.pm | 2 +- Bugzilla/Hook.pm | 204 ++++++---------------- Bugzilla/Install/DB.pm | 2 +- Bugzilla/Install/Requirements.pm | 48 ++---- Bugzilla/Install/Util.pm | 122 +++++++++++-- Bugzilla/Mailer.pm | 2 +- Bugzilla/Object.pm | 10 +- Bugzilla/Search.pm | 2 +- Bugzilla/Template.pm | 10 +- 17 files changed, 563 insertions(+), 227 deletions(-) create mode 100644 Bugzilla/Extension.pm (limited to 'Bugzilla') diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm index 42372393c..f3210425f 100644 --- a/Bugzilla/Attachment.pm +++ b/Bugzilla/Attachment.pm @@ -561,7 +561,7 @@ sub _check_data { $data = <$fh>; } } - Bugzilla::Hook::process('attachment-process_data', { data => \$data, + Bugzilla::Hook::process('attachment_process_data', { data => \$data, attributes => $params }); # Do not validate the size if we have a filehandle. It will be checked later. diff --git a/Bugzilla/Auth/Login/Stack.pm b/Bugzilla/Auth/Login/Stack.pm index a5752f22b..bef9171c9 100644 --- a/Bugzilla/Auth/Login/Stack.pm +++ b/Bugzilla/Auth/Login/Stack.pm @@ -35,7 +35,7 @@ sub new { my $list = shift; my %methods = map { $_ => "Bugzilla/Auth/Login/$_.pm" } split(',', $list); lock_keys(%methods); - Bugzilla::Hook::process('auth-login_methods', { modules => \%methods }); + Bugzilla::Hook::process('auth_login_methods', { modules => \%methods }); $self->{_stack} = []; foreach my $login_method (split(',', $list)) { diff --git a/Bugzilla/Auth/Verify/Stack.pm b/Bugzilla/Auth/Verify/Stack.pm index c23b532fd..2df3fcd25 100644 --- a/Bugzilla/Auth/Verify/Stack.pm +++ b/Bugzilla/Auth/Verify/Stack.pm @@ -30,7 +30,7 @@ sub new { my $self = $class->SUPER::new(@_); my %methods = map { $_ => "Bugzilla/Auth/Verify/$_.pm" } split(',', $list); lock_keys(%methods); - Bugzilla::Hook::process('auth-verify_methods', { modules => \%methods }); + Bugzilla::Hook::process('auth_verify_methods', { modules => \%methods }); $self->{_stack} = []; foreach my $verify_method (split(',', $list)) { diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index c27f23823..d8134e3cb 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -107,7 +107,7 @@ sub DB_COLUMNS { $dbh->sql_date_format('deadline', '%Y-%m-%d') . ' AS deadline', @custom_names); - Bugzilla::Hook::process("bug-columns", { columns => \@columns }); + Bugzilla::Hook::process("bug_columns", { columns => \@columns }); return @columns; } @@ -543,7 +543,7 @@ sub create { $dbh->do('INSERT INTO longdescs (' . join(',', @columns) . ") VALUES ($qmarks)", undef, @values); - Bugzilla::Hook::process('bug-end_of_create', { bug => $bug, + Bugzilla::Hook::process('bug_end_of_create', { bug => $bug, timestamp => $timestamp, }); @@ -613,7 +613,7 @@ sub run_create_validators { delete $params->{lastdiffed}; delete $params->{bug_id}; - Bugzilla::Hook::process('bug-end_of_create_validators', + Bugzilla::Hook::process('bug_end_of_create_validators', { params => $params }); return $params; @@ -870,7 +870,7 @@ sub update { $changes->{'dup_id'} = [$old_dup || undef, $cur_dup || undef]; } - Bugzilla::Hook::process('bug-end_of_update', { bug => $self, + Bugzilla::Hook::process('bug_end_of_update', { bug => $self, timestamp => $delta_ts, changes => $changes, }); @@ -1779,7 +1779,7 @@ sub fields { # Custom Fields map { $_->name } Bugzilla->active_custom_fields ); - Bugzilla::Hook::process("bug-fields", {'fields' => \@fields} ); + Bugzilla::Hook::process('bug_fields', {'fields' => \@fields} ); return @fields; } diff --git a/Bugzilla/Config.pm b/Bugzilla/Config.pm index cab18b5a1..ceb1861ed 100644 --- a/Bugzilla/Config.pm +++ b/Bugzilla/Config.pm @@ -68,7 +68,7 @@ sub _load_params { } # This hook is also called in editparams.cgi. This call here is required # to make SetParam work. - Bugzilla::Hook::process('config-modify_panels', + Bugzilla::Hook::process('config_modify_panels', { panels => \%hook_panels }); } # END INIT CODE @@ -84,7 +84,7 @@ sub param_panels { $param_panels->{$module} = "Bugzilla::Config::$module" unless $module eq 'Common'; } # Now check for any hooked params - Bugzilla::Hook::process('config-add_panels', + Bugzilla::Hook::process('config_add_panels', { panel_modules => $param_panels }); return $param_panels; } diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index c5003f798..f34f05e2f 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -1635,7 +1635,7 @@ sub _initialize { if exists $abstract_schema->{$table}; } unlock_keys(%$abstract_schema); - Bugzilla::Hook::process('db_schema-abstract_schema', + Bugzilla::Hook::process('db_schema_abstract_schema', { schema => $abstract_schema }); unlock_hash(%$abstract_schema); } diff --git a/Bugzilla/Error.pm b/Bugzilla/Error.pm index 661c72f74..dbd9688a9 100644 --- a/Bugzilla/Error.pm +++ b/Bugzilla/Error.pm @@ -107,7 +107,7 @@ sub _throw_error { # Clone the hash so we aren't modifying the constant. my %error_map = %{ WS_ERROR_CODE() }; require Bugzilla::Hook; - Bugzilla::Hook::process('webservice-error_codes', + Bugzilla::Hook::process('webservice_error_codes', { error_map => \%error_map }); my $code = $error_map{$error}; if (!$code) { diff --git a/Bugzilla/Extension.pm b/Bugzilla/Extension.pm new file mode 100644 index 000000000..1046e09ae --- /dev/null +++ b/Bugzilla/Extension.pm @@ -0,0 +1,364 @@ +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Bugzilla Bug Tracking System. +# +# The Initial Developer of the Original Code is Everything Solved, Inc. +# Portions created by the Initial Developers are Copyright (C) 2009 the +# Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Max Kanat-Alexander + +package Bugzilla::Extension; +use strict; + +use Bugzilla::Constants; +use Bugzilla::Error; +use Bugzilla::Install::Util qw(extension_code_files); + +use File::Basename qw(basename); + +#################### +# Subclass Methods # +#################### + +sub new { + my ($class, $params) = @_; + $params ||= {}; + bless $params, $class; + return $params; +} + +####################################### +# Class (Bugzilla::Extension) Methods # +####################################### + +sub load { + my ($class, $extension_file, $config_file) = @_; + require $config_file if $config_file; + + my $package; + # This is needed during checksetup.pl, because Extension packages can + # only be loaded once (they return "1" the second time they're loaded, + # instead of their name). If an extension has only an Extension.pm, + # and no Config.pm, the Extension.pm gets loaded by + # Bugzilla::Install::Requirements before this load() method is ever + # called. + my $map = Bugzilla->request_cache->{extension_requirement_package_map}; + if ($map and defined $map->{$extension_file}) { + $package = $map->{$extension_file}; + } + else { + my $name = require $extension_file; + if ($name =~ /^\d+$/) { + ThrowCodeError('extension_must_return_name', + { extension => $extension_file, returned => $name }); + } + $package = "${class}::$name"; + } + + if (!eval { $package->NAME }) { + ThrowCodeError('extension_no_name', + { filename => $extension_file, package => $package }); + } + + if (!$package->isa($class)) { + ThrowCodeError('extension_must_be_subclass', + { filename => $extension_file, + package => $package, + class => $class }); + } + + return $package; +} + +sub load_all { + my $class = shift; + my $file_sets = extension_code_files(); + my @packages; + foreach my $file_set (@$file_sets) { + my $package = $class->load(@$file_set); + push(@packages, $package); + } + + return \@packages; +} + +#################### +# Instance Methods # +#################### + +use constant enabled => 1; + +1; + +__END__ + +=head1 NAME + +Bugzilla::Extension - Base class for Bugzilla Extensions. + +=head1 SYNOPSIS + +The following would be in F or +F: + + package Bugzilla::Extension::Foo + use strict; + use base qw(Bugzilla::Extension); + + our $VERSION = '0.02'; + use constant NAME => 'Foo'; + + sub some_hook_name { ... } + + __PACKAGE__->NAME; + +=head1 DESCRIPTION + +This is the base class for all Bugzilla extensions. + +=head1 WRITING EXTENSIONS + +The L above gives a pretty good overview of what's basically +required to write an extension. This section gives more information +on exactly how extensions work and how you write them. + +=head2 Example Extension + +There is a sample extension in F that demonstrates +most of the things described in this document, so if you find the +documentation confusing, try just reading the code instead. + +=head2 Where Extension Code Goes + +Extension code lives under the F directory in Bugzilla. + +There are two ways to write extensions: + +=over + +=item 1 + +If your extension will have only code and no templates or other files, +you can create a simple C<.pm> file in the F directory. + +For example, if you wanted to create an extension called "Foo" using this +method, you would put your code into a file called F. + +=item 2 + +If you plan for your extension to have templates and other files, you +can create a whole directory for your extension, and the main extension +code would go into a file called F in that directory. + +For example, if you wanted to create an extension called "Foo" using this +method, you would put your code into a file called +F. + +=back + +=head2 The Extension C. + +The "name" of an extension shows up in several places: + +=over + +=item 1 + +The name of the package: + +C + +=item 2 + +In a C constant that B be defined for every extension: + +C<< use constant NAME => 'Foo'; >> + +=item 3 + +At the very end of the file: + +C<< __PACKAGE__->NAME; >> + +You'll notice that though most Perl packages end with C<1;>, Bugzilla +Extensions must B end with C<< __PACKAGE__->NAME; >>. + +=back + +The name must be identical in all of those locations. + +=head2 Hooks + +In L, there is a L. +These are the various areas of Bugzilla that an extension can "hook" into, +which allow your extension to perform code during that point in Bugzilla's +execution. + +If your extension wants to implement a hook, all you have to do is +write a subroutine in your hook package that has the same name as +the hook. The subroutine will be called as a method on your extension, +and it will get the arguments specified in the hook's documentation as +named parameters in a hashref. + +For example, here's an implementation of a hook named C +that gets an argument named C: + + sub foo_start { + my ($self, $params) = @_; + my $bar = $params->{bar}; + print "I got $bar!\n"; + } + +And that would go into your extension's code file--the file that was +described in the L section above. + +During your subroutine, you may want to know what values were passed +as CGI arguments to the current script, or what arguments were passed to +the current WebService method. You can get that data via +. + +=head2 If Your Extension Requires Certain Perl Modules + +If there are certain Perl modules that your extension requires in order +to run, there is a way you can tell Bugzilla this, and then L +will make sure that those modules are installed, when you run L. + +To do this, you need to specify a constant called C +in your extension. This constant has the same format as +L. + +If there are optional modules that add additional functionality to your +application, you can specify them in a constant called OPTIONAL_MODULES, +which has the same format as +L. + +=head3 If Your Extension Needs Certain Modules In Order To Compile + +If your extension needs a particular Perl module in order to +I, then you have a "chicken and egg" problem--in order to +read C, we have to compile your extension. In order +to compile your extension, we need to already have the modules in +C! + +To get around this problem, Bugzilla allows you to have an additional +file, besides F, called F, that contains +just C. If you have a F, it must also +contain the C constant, instead of your main F +containing the C constant. + +The contents of the file would look something like this for an extension +named C: + + package Bugzilla::Extension::Foo; + use strict; + use constant NAME => 'Foo'; + use constant REQUIRED_MODULES => [ + { + package => 'Some-Package', + module => 'Some::Module', + version => 0, + } + ]; + __PACKAGE__->NAME; + +Note that it is I a subclass of C, because +at the time that module requirements are being checked in L, +C cannot be loaded. Also, just like F, +it ends with C<< __PACKAGE__->NAME; >>. Note also that it has the exact +same C name as F. + +This file may not use any Perl modules other than L, +L, L, and +modules that ship with Perl itself. + +If you want to define both C and C, +they must both be in F or both in F. + +Every time your extension is loaded by Bugzilla, F will be +read and then F will be read, so your methods in F +will have access to everything in F. Don't define anything +with an identical name in both files, or Perl may throw a warning that +you are redefining things. + +This method of setting C is of course not available if +your extension is a single file named C. + +If any of this is confusing, just look at the code of the Example extension. +It uses this method to specify requirements. + +=head2 Disabling Your Extension + +If you want your extension to be totally ignored by Bugzilla (it will +not be compiled or seen to exist at all), then create a file called +C in your extension's directory. (If your extension is just +a file, like F, you cannot use this method to disable +your extension, and will just have to remove it from the directory if you +want to totally disable it.) Note that if you are running under mod_perl, +you may have to restart your web server for this to take effect. + +If you want your extension to be compiled and have L check +for its module pre-requisites, but you don't want the module to be used +by Bugzilla, then you should make your extension's L method +return C<0> or some false value. + +=head1 ADDITIONAL CONSTANTS + +In addition to C, there are some other constants you might +want to define: + +=head2 C<$VERSION> + +This should be a string that describes what version of your extension +this is. Something like C<1.0>, C<1.3.4> or a similar string. + +There are no particular restrictions on the format of version numbers, +but you should probably keep them to just numbers and periods, in the +interest of other software that parses version numbers. + +By default, this will be C if you don't define it. + +=head1 SUBCLASS METHODS + +In addition to hooks, there are a few methods that your extension can +define to modify its behavior, if you want: + +=head2 C + +This should return C<1> if this extension's hook code should be run +by Bugzilla, and C<0> otherwise. + +=head2 C + +Once every request, this method is called on your extension in order +to create an "instance" of it. (Extensions are treated like objects--they +are instantiated once per request in Bugzilla, and then methods are +called on the object.) + +=head1 BUGZILLA::EXTENSION CLASS METHODS + +These are used internally by Bugzilla to load and set up extensions. +If you are an extension author, you don't need to care about these. + +=head2 C + +Takes two arguments, the path to F and the path to F, +for an extension. Loads the extension's code packages into memory using +C, does some sanity-checking on the extension, and returns the +package name of the loaded extension. + +=head2 C + +Calls L for every enabled extension installed into Bugzilla, +and returns an arrayref of all the package names that were loaded. diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm index 8315a3ef6..2fa4c8ded 100644 --- a/Bugzilla/Flag.pm +++ b/Bugzilla/Flag.pm @@ -533,7 +533,7 @@ sub update_flags { my @new_summaries = $class->snapshot($self->flags); my @changes = $class->update_activity(\@old_summaries, \@new_summaries); - Bugzilla::Hook::process('flag-end_of_update', { object => $self, + Bugzilla::Hook::process('flag_end_of_update', { object => $self, timestamp => $timestamp, old_flags => \@old_summaries, new_flags => \@new_summaries, diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm index dc1cd6be1..24a7d73c2 100644 --- a/Bugzilla/Hook.pm +++ b/Bugzilla/Hook.pm @@ -18,88 +18,25 @@ # Rights Reserved. # # Contributor(s): Zach Lipton -# +# Max Kanat-Alexander package Bugzilla::Hook; use strict; - use Bugzilla::Constants; -use Bugzilla::Util; -use Bugzilla::Error; - -use Scalar::Util qw(blessed); - -BEGIN { - if ($ENV{MOD_PERL}) { - require ModPerl::Const; - import ModPerl::Const -compile => 'EXIT'; - } - else { - # Create a fake constant. We have to do this in a string eval, - # otherwise this will always be defined. - eval('sub ModPerl::EXIT;'); - } -} sub process { my ($name, $args) = @_; - - # get a list of all extensions - my @extensions = glob(bz_locations()->{'extensionsdir'} . "/*"); - - # check each extension to see if it uses the hook - # if so, invoke the extension source file: - foreach my $extension (@extensions) { - # all of these variables come directly from code or directory names. - # If there's malicious data here, we have much bigger issues to - # worry about, so we can safely detaint them: - trick_taint($extension); - # Skip CVS directories and any hidden files/dirs. - next if $extension =~ m{/CVS$} || $extension =~ m{/\.[^/]+$}; - next if -e "$extension/disabled"; - if (-e $extension.'/code/'.$name.'.pl') { - Bugzilla->hook_args($args); - # Allow extensions to load their own libraries. - local @INC = ("$extension/lib", @INC); - do($extension.'/code/'.$name.'.pl'); - if ($@) { - if ($ENV{MOD_PERL} and blessed $@ and $@ == ModPerl::EXIT) { - exit; - } - else { - ThrowCodeError('extension_invalid', - { errstr => $@, name => $name, - extension => $extension }); - } - } - # Flush stored data. - Bugzilla->hook_args({}); + foreach my $extension (@{ Bugzilla->extensions }) { + local @INC = @INC; + my $ext_dir = bz_locations()->{'extensionsdir'}; + my $ext_name = $extension->NAME; + unshift(@INC, "$ext_dir/$ext_name/lib"); + if ($extension->can($name)) { + $extension->$name($args); } } } -sub enabled_plugins { - my $extdir = bz_locations()->{'extensionsdir'}; - my @extensions = glob("$extdir/*"); - my %enabled; - foreach my $extension (@extensions) { - trick_taint($extension); - my $extname = $extension; - $extname =~ s{^\Q$extdir\E/}{}; - next if $extname eq 'CVS' || $extname =~ /^\./; - next if -e "$extension/disabled"; - # Allow extensions to load their own libraries. - local @INC = ("$extension/lib", @INC); - $enabled{$extname} = do("$extension/info.pl"); - ThrowCodeError('extension_invalid', - { errstr => $@, name => 'version', - extension => $extension }) if $@; - - } - - return \%enabled; -} - 1; __END__ @@ -122,39 +59,16 @@ hooks. When a piece of standard Bugzilla code wants to allow an extension to perform additional functions, it uses Bugzilla::Hook's L subroutine to invoke any extension code if installed. -There is a sample extension in F that demonstrates -most of the things described in this document, as well as many of the -hooks available. +The implementation of extensions is described in L. =head2 How Hooks Work -When a hook named C is run, Bugzilla will attempt to invoke any -source files named F. - -So, for example, if your extension is called "testopia", and you -want to have code run during the L hook, you -would have a file called F -that contained perl code to run during that hook. - -=head2 Arguments Passed to Hooks - -Some L have params that are passed to them. +When a hook named C is run, Bugzilla looks through all +enabled L for extensions that implement +a subroutined named C. -These params are accessible through L. -That returns a hashref. Very frequently, if you want your -hook to do anything, you have to modify these variables. - -You may also want to use L to get parameters -that were passed to the current CGI script or WebService method. - -=head2 Versioning Extensions - -Every extension must have a file in its root called F. -This file must return a hash when called with C. -The hash must contain a 'version' key with the current version of the -extension. Extension authors can also add any extra infomration to this hash if -required, by adding a new key beginning with x_ which will not be used the -core Bugzilla code. +See L for more details about how an extension +can run code during a hook. =head1 SUBROUTINES @@ -194,7 +108,7 @@ This describes what hooks exist in Bugzilla currently. They are mostly in alphabetical order, but some related hooks are near each other instead of being alphabetical. -=head2 attachment-process_data +=head2 attachment_process_data This happens at the very beginning process of the attachment creation. You can edit the attachment content itself as well as all attributes @@ -212,7 +126,7 @@ L. The data it contains hasn't been checked yet. =back -=head2 auth-login_methods +=head2 auth_login_methods This allows you to add new login types to Bugzilla. (See L.) @@ -243,13 +157,13 @@ login methods that weren't passed to L.) =back -=head2 auth-verify_methods +=head2 auth_verify_methods This works just like L except it's for login verification methods (See L.) It also takes a C parameter, just like L. -=head2 bug-columns +=head2 bug_columns This allows you to add new fields that will show up in every L object. Note that you will also need to use the L hook in @@ -264,7 +178,7 @@ your column name(s) onto the array. =back -=head2 bug-end_of_create +=head2 bug_end_of_create This happens at the end of L, after all other changes are made to the database. This occurs inside a database transaction. @@ -280,7 +194,7 @@ values. =back -=head2 bug-end_of_create_validators +=head2 bug_end_of_create_validators This happens during L, after all parameters have been validated, but before anything has been inserted into the database. @@ -295,7 +209,7 @@ A hashref. The validated parameters passed to C. =back -=head2 bug-end_of_update +=head2 bug_end_of_update This happens at the end of L, after all other changes are made to the database. This generally occurs inside a database transaction. @@ -314,7 +228,7 @@ C<$changes-E{field} = [old, new]> =back -=head2 bug-fields +=head2 bug_fields Allows the addition of database fields from the bugs table to the standard list of allowable fields in a L object, so that @@ -331,7 +245,7 @@ your column name(s) onto the array. =back -=head2 bug-format_comment +=head2 bug_format_comment Allows you to do custom parsing on comments before they are displayed. You do this by returning two regular expressions: one that matches the section you @@ -396,7 +310,7 @@ the summary line). =back -=head2 buglist-columns +=head2 buglist_columns This happens in buglist.cgi after the standard columns have been defined and right before the display column determination. It gives you the opportunity @@ -424,7 +338,7 @@ The definition is structured as: =back -=head2 colchange-columns +=head2 colchange_columns This happens in F right after the list of possible display columns have been defined and gives you the opportunity to add additional @@ -440,7 +354,7 @@ See L. =back -=head2 config-add_panels +=head2 config_add_panels If you want to add new panels to the Parameters administrative interface, this is where you do it. @@ -461,7 +375,7 @@ extension.) =back -=head2 config-modify_panels +=head2 config_modify_panels This is how you modify already-existing panels in the Parameters administrative interface. For example, if you wanted to add a new @@ -485,7 +399,7 @@ L if you want to add new panels. =back -=head2 enter_bug-entrydefaultvars +=head2 enter_bug_entrydefaultvars This happens right before the template is loaded on enter_bug.cgi. @@ -497,7 +411,7 @@ Params: =back -=head2 flag-end_of_update +=head2 flag_end_of_update This happens at the end of L, after all other changes are made to the database and after emails are sent. It gives you a before/after @@ -523,7 +437,7 @@ changed flags, and search for a specific condition like C. =back -=head2 install-before_final_checks +=head2 install_before_final_checks Allows execution of custom code before the final checks are done in checksetup.pl. @@ -538,37 +452,13 @@ A flag that indicates whether or not checksetup is running in silent mode. =back -=head2 install-requirements - -Because of the way Bugzilla installation works, there can't be a normal -hook during the time that F checks what modules are -installed. (C needs to have those modules installed--it's -a chicken-and-egg problem.) - -So instead of the way hooks normally work, this hook just looks for two -subroutines (or constants, since all constants are just subroutines) in -your file, called C and C, -which should return arrayrefs in the same format as C and -C in L. - -These subroutines will be passed an arrayref that contains the current -Bugzilla requirements of the same type, in case you want to modify -Bugzilla's requirements somehow. (Probably the most common would be to -alter a version number or the "feature" element of C.) - -F will add these requirements to its own. - -Please remember--if you put something in C, then -F B unless the user has that module -installed! So use C whenever you can. - -=head2 install-update_db +=head2 install_update_db This happens at the very end of all the tables being updated during an installation or upgrade. If you need to modify your custom schema, do it here. No params are passed. -=head2 db_schema-abstract_schema +=head2 db_schema_abstract_schema This allows you to add tables to Bugzilla. Note that we recommend that you prefix the names of your tables with some word, so that they don't conflict @@ -588,7 +478,7 @@ database when run. =back -=head2 mailer-before_send +=head2 mailer_before_send Called right before L sends a message to the MTA. @@ -600,7 +490,7 @@ Params: =back -=head2 object-before_create +=head2 object_before_create This happens at the beginning of L. @@ -620,7 +510,7 @@ A hashref. The set of named parameters passed to C. =back -=head2 object-before_set +=head2 object_before_set Called during L, before any actual work is done. You can use this to perform actions before a value is changed for @@ -646,7 +536,7 @@ The value being set on the object. =back -=head2 object-end_of_create_validators +=head2 object_end_of_create_validators Called at the end of L. You can use this to run additional validation when creating an object. @@ -671,7 +561,7 @@ validated by the C specified for the object. =back -=head2 object-end_of_set_all +=head2 object_end_of_set_all This happens at the end of L. This is a good place to call custom set_ functions on objects, or to make changes @@ -693,7 +583,7 @@ A hashref. The set of named parameters passed to C. =back -=head2 object-end_of_update +=head2 object_end_of_update Called during L, after changes are made to the database, but while still inside a transaction. @@ -719,7 +609,7 @@ L returns. =back -=head2 page-before_template +=head2 page_before_template This is a simple way to add your own pages to Bugzilla. This hooks C, which loads templates from F