1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>
Bugzilla</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" title="style" type="text/css" href="./../../../style.css" media="all" >
</head>
<body id="pod">
<p class="backlinktop"><b><a name="___top" href="index.html" accesskey="1" title="All Documents"><<</a></b></p>
<h1>Bugzilla</h1>
<div class='indexgroup'>
<ul class='indexList indexList1'>
<li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
<li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
<li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
<li class='indexItem indexItem1'><a href='#METHODS'>METHODS</a>
</ul>
</div>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>
<p>Bugzilla - Semi-persistent collection of various objects used by scripts and modules</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS</a></h1>
<pre class="code"> use Bugzilla;
sub someModulesSub {
Bugzilla->dbh->prepare(...);
Bugzilla->template->process(...);
}</pre>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>
<p>Several Bugzilla 'things' are used by a variety of modules and scripts. This includes database handles, template objects, and so on.</p>
<p>This module is a singleton intended as a central place to store these objects. This approach has several advantages:</p>
<ul>
<li>They're not global variables, so we don't have issues with them staying around with mod_perl</li>
<li>Everything is in one central place, so it's easy to access, modify, and maintain</li>
<li>Code in modules can get access to these objects without having to have them all passed from the caller, and the caller's caller, and....</li>
<li>We can reuse objects across requests using mod_perl where appropriate (eg templates), whilst destroying those which are only valid for a single request (such as the current user)</li>
</ul>
<p>Note that items accessible via this object are demand-loaded when requested.</p>
<p>For something to be added to this object, it should either be able to benefit from persistence when run under mod_perl (such as the a <code class="code">template</code> object), or should be something which is globally required by a large ammount of code (such as the current <code class="code">user</code> object).</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="METHODS"
>METHODS</a></h1>
<p>Note that all <code class="code">Bugzilla</code> functionality is method based; use <code class="code">Bugzilla->dbh</code> rather than <code class="code">Bugzilla::dbh</code>. Nothing cares about this now, but don't rely on that.</p>
<dl>
<dt><a name="template"
><code class="code">template</code></a></dt>
<dd>
<p>The current <code class="code">Template</code> object, to be used for output</p>
<dt><a name="template_inner"
><code class="code">template_inner</code></a></dt>
<dd>
<p>If you ever need a <a href="./Bugzilla/Template.html" class="podlinkpod"
>Bugzilla::Template</a> object while you're already processing a template, use this. Also use it if you want to specify the language to use. If no argument is passed, it uses the last language set. If the argument is "" (empty string), the language is reset to the current one (the one used by Bugzilla->template).</p>
<dt><a name="cgi"
><code class="code">cgi</code></a></dt>
<dd>
<p>The current <code class="code">cgi</code> object. Note that modules should <b>not</b> be using this in general. Not all Bugzilla actions are cgi requests. Its useful as a convenience method for those scripts/templates which are only use via CGI, though.</p>
<dt><a name="input_params"
><code class="code">input_params</code></a></dt>
<dd>
<p>When running under the WebService, this is a hashref containing the arguments passed to the WebService method that was called. When running in a normal script, this is a hashref containing the contents of the CGI parameters.</p>
<p>Modifying this hashref will modify the CGI parameters or the WebService arguments (depending on what <code class="code">input_params</code> currently represents).</p>
<p>This should be used instead of <a href="#cgi" class="podlinkpod"
>"cgi"</a> in situations where your code could be being called by either a normal CGI script or a WebService method, such as during a code hook.</p>
<p><b>Note:</b> When <code class="code">input_params</code> represents the CGI parameters, any parameter specified more than once (like <code class="code">foo=bar&foo=baz</code>) will appear as an arrayref in the hash, but any value specified only once will appear as a scalar. This means that even if a value <i>can</i> appear multiple times, if it only <i>does</i> appear once, then it will be a scalar in <code class="code">input_params</code>, not an arrayref.</p>
<dt><a name="user"
><code class="code">user</code></a></dt>
<dd>
<p><code class="code">undef</code> if there is no currently logged in user or if the login code has not yet been run. If an sudo session is in progress, the <code class="code">Bugzilla::User</code> corresponding to the person who is being impersonated. If no session is in progress, the current <code class="code">Bugzilla::User</code>.</p>
<dt><a name="set_user"
><code class="code">set_user</code></a></dt>
<dd>
<p>Allows you to directly set what <a href="#user" class="podlinkpod"
>"user"</a> will return. You can use this if you want to bypass <a href="#login" class="podlinkpod"
>"login"</a> for some reason and directly "log in" a specific <a href="./Bugzilla/User.html" class="podlinkpod"
>Bugzilla::User</a>. Be careful with it, though!</p>
<dt><a name="sudoer"
><code class="code">sudoer</code></a></dt>
<dd>
<p><code class="code">undef</code> if there is no currently logged in user, the currently logged in user is not in the <i>sudoer</i> group, or there is no session in progress. If an sudo session is in progress, returns the <code class="code">Bugzilla::User</code> object corresponding to the person who logged in and initiated the session. If no session is in progress, returns the <code class="code">Bugzilla::User</code> object corresponding to the currently logged in user.</p>
<dt><a
><code class="code">sudo_request</code> This begins an sudo session for the current request. It is meant to be used when a session has just started. For normal use, sudo access should normally be set at login time.</a></dt>
<dd>
<dt><a name="login"
><code class="code">login</code></a></dt>
<dd>
<p>Logs in a user, returning a <code class="code">Bugzilla::User</code> object, or <code class="code">undef</code> if there is no logged in user. See <a href="./Bugzilla/Auth.html" class="podlinkpod"
>Bugzilla::Auth</a>, and <a href="./Bugzilla/User.html" class="podlinkpod"
>Bugzilla::User</a>.</p>
<dt><a name="page_requires_login"
><code class="code">page_requires_login</code></a></dt>
<dd>
<p>If the current page always requires the user to log in (for example, <code class="code">enter_bug.cgi</code> or any page called with <code class="code">?GoAheadAndLogIn=1</code>) then this will return something true. Otherwise it will return false. (This is set when you call <a href="#login" class="podlinkpod"
>"login"</a>.)</p>
<dt><a name="logout($option)"
><code class="code">logout($option)</code></a></dt>
<dd>
<p>Logs out the current user, which involves invalidating user sessions and cookies. Three options are available from <a href="./Bugzilla/Constants.html" class="podlinkpod"
>Bugzilla::Constants</a>: LOGOUT_CURRENT (the default), LOGOUT_ALL or LOGOUT_KEEP_CURRENT.</p>
<dt><a name="logout_user($user)"
><code class="code">logout_user($user)</code></a></dt>
<dd>
<p>Logs out the specified user (invalidating all his sessions), taking a Bugzilla::User instance.</p>
<dt><a name="logout_by_id($id)"
><code class="code">logout_by_id($id)</code></a></dt>
<dd>
<p>Logs out the user with the id specified. This is a compatibility function to be used in callsites where there is only a userid and no Bugzilla::User instance.</p>
<dt><a name="logout_request"
><code class="code">logout_request</code></a></dt>
<dd>
<p>Essentially, causes calls to <code class="code">Bugzilla->user</code> to return <code class="code">undef</code>. This has the effect of logging out a user for the current request only; cookies and database sessions are left intact.</p>
<dt><a name="fields"
><code class="code">fields</code></a></dt>
<dd>
<p>This is the standard way to get arrays or hashes of <a href="./Bugzilla/Field.html" class="podlinkpod"
>Bugzilla::Field</a> objects when you need them. It takes the following named arguments in a hashref:</p>
<dl>
<dt><a name="by_name"
><code class="code">by_name</code></a></dt>
<dd>
<p>If false (or not specified), this method will return an arrayref of the requested fields. The order of the returned fields is random.</p>
<p>If true, this method will return a hashref of fields, where the keys are field names and the valules are <a href="./Bugzilla/Field.html" class="podlinkpod"
>Bugzilla::Field</a> objects.</p>
<dt><a name="type"
><code class="code">type</code></a></dt>
<dd>
<p>Either a single <code class="code">FIELD_TYPE_*</code> constant or an arrayref of them. If specified, the returned fields will be limited to the types in the list. If you don't specify this argument, all fields will be returned.</p>
</dd>
</dl>
<dt><a name="error_mode"
><code class="code">error_mode</code></a></dt>
<dd>
<p>Call either <code class="code">Bugzilla-</code>error_mode(Bugzilla::Constants::ERROR_MODE_DIE)> or <code class="code">Bugzilla-</code>error_mode(Bugzilla::Constants::ERROR_MODE_DIE_SOAP_FAULT)> to change this flag's default of <code class="code">Bugzilla::Constants::ERROR_MODE_WEBPAGE</code> and to indicate that errors should be passed to error mode specific error handlers rather than being sent to a browser and finished with an exit().</p>
<p>This is useful, for example, to keep <code class="code">eval</code> blocks from producing wild HTML on errors, making it easier for you to catch them. (Remember to reset the error mode to its previous value afterwards, though.)</p>
<p><code class="code">Bugzilla-</code>error_mode> will return the current state of this flag.</p>
<p>Note that <code class="code">Bugzilla-</code>error_mode> is being called by <code class="code">Bugzilla-</code>usage_mode> on usage mode changes.</p>
<dt><a name="usage_mode"
><code class="code">usage_mode</code></a></dt>
<dd>
<p>Call either <code class="code">Bugzilla-</code>usage_mode(Bugzilla::Constants::USAGE_MODE_CMDLINE)> or <code class="code">Bugzilla-</code>usage_mode(Bugzilla::Constants::USAGE_MODE_XMLRPC)> near the beginning of your script to change this flag's default of <code class="code">Bugzilla::Constants::USAGE_MODE_BROWSER</code> and to indicate that Bugzilla is being called in a non-interactive manner.</p>
<p>This influences error handling because on usage mode changes, <code class="code">usage_mode</code> calls <code class="code">Bugzilla-</code>error_mode> to set an error mode which makes sense for the usage mode.</p>
<p><code class="code">Bugzilla-</code>usage_mode> will return the current state of this flag.</p>
<dt><a name="installation_mode"
><code class="code">installation_mode</code></a></dt>
<dd>
<p>Determines whether or not installation should be silent. See <a href="./Bugzilla/Constants.html" class="podlinkpod"
>Bugzilla::Constants</a> for the <code class="code">INSTALLATION_MODE</code> constants.</p>
<dt><a name="installation_answers"
><code class="code">installation_answers</code></a></dt>
<dd>
<p>Returns a hashref representing any "answers" file passed to <em class="code">checksetup.pl</em>, used to automatically answer or skip prompts.</p>
<dt><a name="dbh"
><code class="code">dbh</code></a></dt>
<dd>
<p>The current database handle. See <a href="./DBI.html" class="podlinkpod"
>DBI</a>.</p>
<dt><a name="dbh_main"
><code class="code">dbh_main</code></a></dt>
<dd>
<p>The main database handle. See <a href="./DBI.html" class="podlinkpod"
>DBI</a>.</p>
<dt><a name="languages"
><code class="code">languages</code></a></dt>
<dd>
<p>Currently installed languages. Returns a reference to a list of RFC 1766 language tags of installed languages.</p>
<dt><a name="switch_to_shadow_db"
><code class="code">switch_to_shadow_db</code></a></dt>
<dd>
<p>Switch from using the main database to using the shadow database.</p>
<dt><a name="switch_to_main_db"
><code class="code">switch_to_main_db</code></a></dt>
<dd>
<p>Change the database object to refer to the main database.</p>
<dt><a name="params"
><code class="code">params</code></a></dt>
<dd>
<p>The current Parameters of Bugzilla, as a hashref. If <code class="code">data/params</code> does not exist, then we return an empty hashref. If <code class="code">data/params</code> is unreadable or is not valid perl, we <code class="code">die</code>.</p>
<dt><a name="local_timezone"
><code class="code">local_timezone</code></a></dt>
<dd>
<p>Returns the local timezone of the Bugzilla installation, as a DateTime::TimeZone object. This detection is very time consuming, so we cache this information for future references.</p>
<dt><a name="job_queue"
><code class="code">job_queue</code></a></dt>
<dd>
<p>Returns a <a href="./Bugzilla/JobQueue.html" class="podlinkpod"
>Bugzilla::JobQueue</a> that you can use for queueing jobs. Will throw an error if job queueing is not correctly configured on this Bugzilla installation.</p>
<dt><a name="feature"
><code class="code">feature</code></a></dt>
<dd>
<p>Tells you whether or not a specific feature is enabled. For names of features, see <code class="code">OPTIONAL_MODULES</code> in <code class="code">Bugzilla::Install::Requirements</code>.</p>
</dd>
</dl>
<p class="backlinkbottom"><b><a name="___bottom" href="index.html" title="All Documents"><<</a></b></p>
<!-- end doc -->
</body></html>
|