1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
6
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7
<link rel="stylesheet" title="style" type="text/css" href="../style.css" media="all" >
11
<p class="backlinktop"><b><a name="___top" href="../index.html" accesskey="1" title="All Documents"><<</a></b></p>
12
<h1>Bugzilla::Hook</h1>
13
<div class='indexgroup'>
14
<ul class='indexList indexList1'>
15
<li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
16
<li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
17
<li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
18
<ul class='indexList indexList2'>
19
<li class='indexItem indexItem2'><a href='#How_Hooks_Work'>How Hooks Work</a>
20
<li class='indexItem indexItem2'><a href='#Arguments_Passed_to_Hooks'>Arguments Passed to Hooks</a>
22
<li class='indexItem indexItem1'><a href='#SUBROUTINES'>SUBROUTINES</a>
23
<li class='indexItem indexItem1'><a href='#HOOKS'>HOOKS</a>
24
<ul class='indexList indexList2'>
25
<li class='indexItem indexItem2'><a href='#enter_bug-entrydefaultvars'>enter_bug-entrydefaultvars</a>
26
<li class='indexItem indexItem2'><a href='#install-requirements'>install-requirements</a>
27
<li class='indexItem indexItem2'><a href='#install-update_db'>install-update_db</a>
28
<li class='indexItem indexItem2'><a href='#db_schema-abstract_schema'>db_schema-abstract_schema</a>
33
<h1><a class='u' href='#___top' title='click to go to top of document'
37
<p>Bugzilla::Hook - Extendible extension hooks for Bugzilla code</p>
39
<h1><a class='u' href='#___top' title='click to go to top of document'
43
<pre class="code"> use Bugzilla::Hook;
45
Bugzilla::Hook::process("hookname", { arg => $value, arg2 => $value2 });</pre>
47
<h1><a class='u' href='#___top' title='click to go to top of document'
51
<p>Bugzilla allows extension modules to drop in and add routines at arbitrary points in Bugzilla code. These points are refered to as hooks. When a piece of standard Bugzilla code wants to allow an extension to perform additional functions, it uses Bugzilla::Hook's <a href="#process" class="podlinkpod"
52
>"process"</a> subroutine to invoke any extension code if installed.</p>
54
<h2><a class='u' href='#___top' title='click to go to top of document'
56
>How Hooks Work</a></h2>
58
<p>When a hook named <code class="code">HOOK_NAME</code> is run, Bugzilla will attempt to invoke any source files named <em class="code">extensions/*/code/HOOK_NAME.pl</em>.</p>
60
<p>So, for example, if your extension is called "testopia", and you want to have code run during the <a href="#install-update_db" class="podlinkpod"
61
>"install-update_db"</a> hook, you would have a file called <em class="code">extensions/testopia/code/install-update_db.pl</em> that contained perl code to run during that hook.</p>
63
<h2><a class='u' href='#___top' title='click to go to top of document'
64
name="Arguments_Passed_to_Hooks"
65
>Arguments Passed to Hooks</a></h2>
67
<p>Some <a href="#HOOKS" class="podlinkpod"
68
>hooks</a> have params that are passed to them.</p>
70
<p>These params are accessible through <a href="../Bugzilla.html#hook_args" class="podlinkpod"
71
>"hook_args" in Bugzilla</a>. That returns a hashref. Very frequently, if you want your hook to do anything, you have to modify these variables.</p>
73
<h1><a class='u' href='#___top' title='click to go to top of document'
79
><code class="code">process</code></a></dt>
83
<dt><a name="Description"
84
><b>Description</b></a></dt>
87
<p>Invoke any code hooks with a matching name from any installed extensions.</p>
89
<p>See <code class="code">customization.xml</code> in the Bugzilla Guide for more information on Bugzilla's extension mechanism.</p>
92
><b>Params</b></a></dt>
96
<dt><a name="$name_-_The_name_of_the_hook_to_invoke."
97
><code class="code">$name</code> - The name of the hook to invoke.
98
<dt><a name="$args_-_A_hashref._The_named_args_to_pass_to_the_hook._They_will_be_accessible_to_the_hook_via_"hook_args"_in_Bugzilla."
99
><code class="code">$args</code> - A hashref. The named args to pass to the hook. They will be accessible to the hook via <a href="../Bugzilla.html#hook_args" class="podlinkpod"
100
>"hook_args" in Bugzilla</a>.</a></dt>
103
<dt><a name="Returns_(nothing)"
104
><b>Returns</b> (nothing)</a></dt>
109
<h1><a class='u' href='#___top' title='click to go to top of document'
113
<p>This describes what hooks exist in Bugzilla currently.</p>
115
<h2><a class='u' href='#___top' title='click to go to top of document'
116
name="enter_bug-entrydefaultvars"
117
>enter_bug-entrydefaultvars</a></h2>
119
<p>This happens right before the template is loaded on enter_bug.cgi.</p>
124
<dt><a name="vars_-_A_hashref._The_variables_that_will_be_passed_into_the_template."
125
><code class="code">vars</code> - A hashref. The variables that will be passed into the template.</a></dt>
128
<h2><a class='u' href='#___top' title='click to go to top of document'
129
name="install-requirements"
130
>install-requirements</a></h2>
132
<p>Because of the way Bugzilla installation works, there can't be a normal hook during the time that <em class="code">checksetup.pl</em> checks what modules are installed. (<code class="code">Bugzilla::Hook</code> needs to have those modules installed--it's a chicken-and-egg problem.)</p>
134
<p>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 <code class="code">OPTIONAL_MODULES</code> and <code class="code">REQUIRED_MODULES</code>, which should return arrayrefs in the same format as <code class="code">OPTIONAL_MODULES</code> and <code class="code">REQUIRED_MODULES</code> in <a href="../Bugzilla/Install/Requirements.html" class="podlinkpod"
135
>Bugzilla::Install::Requirements</a>.</p>
137
<p>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 <code class="code">OPTIONAL_MODULES</code>.)</p>
139
<p><em class="code">checksetup.pl</em> will add these requirements to its own.</p>
141
<p>Please remember--if you put something in <code class="code">REQUIRED_MODULES</code>, then <em class="code">checksetup.pl</em> <b>cannot complete</b> unless the user has that module installed! So use <code class="code">OPTIONAL_MODULES</code> whenever you can.</p>
143
<h2><a class='u' href='#___top' title='click to go to top of document'
144
name="install-update_db"
145
>install-update_db</a></h2>
147
<p>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.</p>
149
<h2><a class='u' href='#___top' title='click to go to top of document'
150
name="db_schema-abstract_schema"
151
>db_schema-abstract_schema</a></h2>
153
<p>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 with any future Bugzilla tables.</p>
155
<p>If you wish to add new <i>columns</i> to existing Bugzilla tables, do that in <a href="#install-update_db" class="podlinkpod"
156
>"install-update_db"</a>.</p>
162
><code class="code">schema</code> - A hashref, in the format of <a href="../Bugzilla/DB/Schema.html#ABSTRACT_SCHEMA" class="podlinkpod"
163
>"ABSTRACT_SCHEMA" in Bugzilla::DB::Schema</a>. Add new hash keys to make new table definitions. <em class="code">checksetup.pl</em> will automatically add these tables to the database when run.</a></dt>
165
<p class="backlinkbottom"><b><a name="___bottom" href="../index.html" title="All Documents"><<</a></b></p>