blib/lib/BZ/Client/Bugzilla.pm untested

filter: Statementstmt 0.0% 0 / 62 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 13 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 106 CC 9 SCAR 20.0
CC
9
Cov
0%
extensions
12.0
parameters
12.0
last_audit_time
6.0
CRAP 7.4
1 #!/bin/false
2 # PODNAME: BZ::Client::Bugzilla
3 # ABSTRACT: Information about the Bugzilla server, i.e. the Bugzilla::Webservices::Bugzilla API
4  
5 use strict;
6 use warnings 'all';
7  
8 package BZ::Client::Bugzilla;
9 $BZ::Client::Bugzilla::VERSION = '4.9';
10  
11 use parent qw( BZ::Client::API );
12  
13 ## functions
14  
15 sub extensions {
16 my($class, $client) = @_;
17 $client->log('debug', $class . '::extensions: Asking');
18 my $result = $class->api_call($client, 'Bugzilla.extensions');
19 $client->log('debug', $class . '::extensions: Got stuff');
20 my $extensions = $result->{'extensions'};
21 if (!$extensions || 'HASH' ne ref($extensions)) {
22 $class->error($client, 'Invalid reply by server, expected hash of extensions.');
23 }
24 return wantarray ? %{$extensions} : $extensions
25 }
26  
27 sub parameters {
28 my($class, $client) = @_;
29 $client->log('debug', $class . '::parameters: Asking');
30 my $result = $class->api_call($client, 'Bugzilla.parameters');
31 $client->log('debug', $class . '::parameters: Got stuff');
32 my $parameters = $result->{'parameters'};
33 if (!$parameters || 'HASH' ne ref($parameters)) {
34 $class->error($client, 'Invalid reply by server, expected hash of parameters.');
35 }
36 $client->log('debug', $class . '::parameters: Got ' . scalar keys %{$parameters});
37 return wantarray ? %{$parameters} : $parameters
38 }
39  
40 sub last_audit_time {
41 my($class, $client, $params) = @_;
42 $client->log('debug', $class . '::last_audit_time: Asking');
43 my $result = $class->api_call($client, 'Bugzilla.last_audit_time', $params);
44 $client->log('debug', $class . '::last_audit_time: Got stuff');
45 my $last_audit_time = $result->{'last_audit_time'};
46 if (!$last_audit_time || ! ref($last_audit_time)) {
47 $class->error($client, 'Invalid reply by server, expected last_audit_time dateTime.');
48 }
49 $client->log('debug', $class . "::last_audit_time: Got $last_audit_time");
50 return $last_audit_time
51 }
52  
53 sub time {
54 my($class, $client) = @_;
55 $client->log('debug', $class . '::time: Asking');
56 my $time = $class->api_call($client, 'Bugzilla.time');
57 $client->log('debug', $class . "::time: Got $time");
58 return wantarray ? %{$time} : $time
59 }
60  
61 sub timezone {
62 my($class, $client) = @_;
63 $client->log('debug', $class . '::timezone: Asking');
64 my $result = $class->api_call($client, 'Bugzilla.timezone');
65 my $timezone = $result->{'timezone'};
66 if (!$timezone || ref($timezone)) {
67 $class->error($client, 'Invalid reply by server, expected timezone scalar.');
68 }
69 $client->log('debug', $class . "::time: Got $timezone");
70 return $timezone
71 }
72  
73 sub version {
74 my($class, $client) = @_;
75 $client->log('debug', $class . '::version: Asking');
76 my $result = $class->api_call($client, 'Bugzilla.version');
77 my $version = $result->{'version'};
78 if (!$version || ref($version)) {
79 $class->error($client, 'Invalid reply by server, expected version scalar.');
80 }
81 $client->log('debug', $class . "::version: Got $version");
82 return $version
83 }
84  
85 1;
86  
87 __END__
88  
89 =pod
90  
91 =encoding UTF-8
92  
93 =head1 NAME
94  
95 BZ::Client::Bugzilla - Information about the Bugzilla server, i.e. the Bugzilla::Webservices::Bugzilla API
96  
97 =head1 VERSION
98  
99 version 4.9
100  
101 =head1 SYNOPSIS
102  
103 This class provides methods for accessing information about the Bugzilla
104 servers installation.
105  
106 my $client = BZ::Client->new( url => $url,
107 user => $user,
108 password => $password );
109  
110 my $extensions = BZ::Client::Bugzilla->extensions( $client );
111 my $time = BZ::Client::Bugzilla->time( $client );
112 my $version = BZ::Client::Bugzilla->version( $client );
113  
114 =head1 CLASS METHODS
115  
116 This section lists the class methods, which are available in this module.
117  
118 =head2 extensions
119  
120 %extensions = BZ::Client::Bugzilla->extensions( $client );
121 $extensions = BZ::Client::Bugzilla->extensions( $client );
122  
123 Returns a hash or hash ref information about the extensions that are currently installed and enabled in this Bugzilla.
124  
125 =head3 History
126  
127 Added in Bugzilla 3.2.
128  
129 As of Bugzilla 3.6, the names of extensions are canonical names that the extensions define themselves. Before 3.6, the names of the extensions depended on the directory they were in on the Bugzilla server.
130  
131 =head3 Parameters
132  
133 (none)
134  
135 =head3 Returns
136  
137 The hash contains the names of extensions as keys, and the values are a hash.
138  
139 That hash contains a single key C<version>, which is the version of the extension, or C<0> if the extension hasn't defined a version.
140  
141 The return value looks something like this:
142  
143 {
144 Example => {
145 version => '3.6',
146 },
147 BmpConvert => {
148 version => '1.0',
149 },
150 }
151  
152 =head2 last_audit_time
153  
154 $last_audit_time = BZ::Client::Bugzilla->extensions( $client, \%params );
155  
156 Gets the latest time of the C<audit_log> table.
157  
158 =head3 History
159  
160 Added in Bugzilla 4.4.
161  
162 =head3 Parameters
163  
164 You can pass the optional parameter L</class> to get the maximum for only the listed classes.
165  
166 =over 4
167  
168 =item class
169  
170 I<class> (array) - An array of strings represetning the class names.
171  
172 Note: The class names are defined as "Bugzilla::class_name". For the product use Bugzilla::Product.
173  
174 =back
175  
176 =head3 Returns
177  
178 The maximum of the C<at_time> from the C<audit_log>, as a L<DateTime> object.
179  
180 =head2 parameters
181  
182 %parameters = BZ::Client::Bugzilla->parameters( $client );
183 $parameters = BZ::Client::Bugzilla->parameters( $client );
184  
185 Returns a hash or hashref containing the current Bugzilla parameters.
186  
187 =head3 History
188  
189 Added in Bugzilla 4.4.
190  
191 =head3 Parameters
192  
193 (none)
194  
195 =head3 Returns
196  
197 A logged-out user can only access the C<maintainer> and C<requirelogin> parameters.
198  
199 A logged-in user can access the following parameters (listed alphabetically): C<allowemailchange>, C<attachment_base>, C<commentonchange_resolution>, C<commentonduplicate>, C<cookiepath>, C<defaultopsys>, C<defaultplatform>, C<defaultpriority>, C<defaultseverity>, C<duplicate_or_move_bug_status>, C<emailregexpdesc>, C<emailsuffix>, C<letsubmitterchoosemilestone>, C<letsubmitterchoosepriority>, C<mailfrom>, C<maintainer>, C<maxattachmentsize>, C<maxlocalattachment>, C<musthavemilestoneonaccept>, C<noresolveonopenblockers>, C<password_complexity>, C<rememberlogin>, C<requirelogin>, C<search_allow_no_criteria>, C<urlbase>, C<use_see_also>, C<useclassification>, C<usemenuforusers>, C<useqacontact>, C<usestatuswhiteboard>, C<usetargetmilestone>.
200  
201 A user in the C<tweakparams> group can access all existing parameters. New parameters can appear or obsolete parameters can disappear depending on the version of Bugzilla and on extensions being installed. The list of parameters returned by this method is not stable and will never be stable.
202  
203 =head2 time
204  
205 %timeinfo = BZ::Client::Bugzilla->time( $client );
206 $timeinfo = BZ::Client::Bugzilla->time( $client );
207  
208 Gets information about what time the Bugzilla server thinks it is, and what timezone it's running in.
209  
210 =head3 History
211  
212 Added in Bugzilla 3.4.
213  
214 Note: As of Bugzilla 3.6, this method returns all data as though the server were in the UTC timezone, instead of returning information in the server's local timezone.
215  
216 =head3 Parameters
217  
218 (none)
219  
220 =head3 Returns
221  
222 A hash with the following items:
223  
224 =over 4
225  
226 =item db_time
227  
228 I<db_time> (L<DateTime>) - The current time in UTC, according to the Bugzilla database server.
229  
230 Note that Bugzilla assumes that the database and the webserver are running in the same time zone. However, if the web server and the database server aren't synchronized for some reason, this is the time that you should rely on for doing searches and other input to the WebService.
231  
232 =item web_time
233  
234 I<web_time> (L<DateTime>) - This is the current time in UTC, according to Bugzilla's web server.
235  
236 This might be different by a second from L</db_time> since this comes from a different source. If it's any more different than a second, then there is likely some problem with this Bugzilla instance. In this case you should rely on the L</db_time>, not the L</web_time>.
237  
238 =item web_time_utc
239  
240 Identical to L</web_time>. (Exists only for backwards-compatibility with versions of Bugzilla before 3.6.)
241  
242 =item tz_name
243  
244 I<tz_name> (string) - The literal string C<UTC>. (Exists only for backwards-compatibility with versions of Bugzilla before 3.6.)
245  
246 =item tz_short_name
247  
248 tz_short_name (string) - The literal string C<UTC>. (Exists only for backwards-compatibility with versions of Bugzilla before 3.6.)
249  
250 =item tz_offset
251  
252 I<tz_offset> (string) - The literal string C<+0000>. (Exists only for backwards-compatibility with versions of Bugzilla before 3.6.)
253  
254 =back
255  
256 =head2 timezone
257  
258 $timezone = BZ::Client::Bugzilla->timezone( $client );
259  
260 Returns the Bugzilla servers timezone as a numeric value. This method
261 is deprecated: Use L</time> instead.
262  
263 Note: as of Bugzilla 3.6 the timezone is always +0000 (UTC)
264 Also, Bugzilla has depreceated but not yet removed this API call
265  
266 =head2 version
267  
268 $version = BZ::Client::Bugzilla->version( $client );
269  
270 Returns the Bugzilla servers version.
271  
272 =head1 EXCEPTION HANDLING
273  
274 See L<BZ::Client::Exception>
275  
276 =head1 SEE ALSO
277  
278 L<BZ::Client>, L<BZ::Client::API>, L<Bugzilla API|https://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bugzilla.html>
279  
280 =head1 AUTHORS
281  
282 =over 4
283  
284 =item *
285  
286 Dean Hamstead <dean@bytefoundry.com.au>
287  
288 =item *
289  
290 Jochen Wiedmann <jochen.wiedmann@gmail.com>
291  
292 =back
293  
294 =head1 COPYRIGHT AND LICENSE
295  
296 This software is copyright (c) 2026 by Dean Hamstad.
297  
298 This is free software; you can redistribute it and/or modify it under
299 the same terms as the Perl 5 programming language system itself.
300  
301 =cut