Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
dc4fc18f
Commit
dc4fc18f
authored
Oct 19, 2007
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 396245: Allow the WebService to list the installed plugins and their versions
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=ghendricks, a=mkanat
parent
f567c6d3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
1 deletion
+93
-1
Hook.pm
Bugzilla/Hook.pm
+34
-1
Bugzilla.pm
Bugzilla/WebService/Bugzilla.pm
+28
-0
version.pl
extensions/example/version.pl
+31
-0
No files found.
Bugzilla/Hook.pm
View file @
dc4fc18f
...
...
@@ -41,6 +41,8 @@ sub process {
# 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
);
...
...
@@ -53,7 +55,28 @@ sub process {
Bugzilla
->
hook_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/version.pl"
);
ThrowCodeError
(
'extension_invalid'
,
{
errstr
=>
$@
,
name
=>
'version'
,
extension
=>
$extension
})
if
$@
;
}
return
\%
enabled
;
}
1
;
...
...
@@ -78,6 +101,10 @@ hooks. When a piece of standard Bugzilla code wants to allow an extension
to perform additional functions, it uses Bugzilla::Hook's L</process>
subroutine to invoke any extension code if installed.
There is a sample extension in F<extensions/example/> that demonstrates
most of the things described in this document, as well as many of the
hooks available.
=head2 How Hooks Work
When a hook named C<HOOK_NAME> is run, Bugzilla will attempt to invoke any
...
...
@@ -96,6 +123,12 @@ These params are accessible through L<Bugzilla/hook_args>.
That returns a hashref. Very frequently, if you want your
hook to do anything, you have to modify these variables.
=head2 Versioning Extensions
Every extension must have a file in its root called F<version.pl>.
This file should return a version number when called with C<do>.
This represents the current version of this extension.
=head1 SUBROUTINES
=over
...
...
Bugzilla/WebService/Bugzilla.pm
View file @
dc4fc18f
...
...
@@ -21,6 +21,7 @@ package Bugzilla::WebService::Bugzilla;
use
strict
;
use
base
qw(Bugzilla::WebService)
;
use
Bugzilla::
Constants
;
use
Bugzilla::
Hook
;
import
SOAP::
Data
qw(type)
;
use
Time::
Zone
;
...
...
@@ -29,6 +30,14 @@ sub version {
return
{
version
=>
type
(
'string'
)
->
value
(
BUGZILLA_VERSION
)
};
}
sub
plugins
{
my
$plugins
=
Bugzilla::Hook::
enabled_plugins
();
foreach
my
$name
(
keys
%
$plugins
)
{
$plugins
->
{
$name
}
=
type
(
'string'
)
->
value
(
$plugins
->
{
$name
});
}
return
{
plugins
=>
$plugins
};
}
sub
timezone
{
my
$offset
=
tz_offset
();
$offset
=
((
$offset
/ 60) /
60
)
*
100
;
...
...
@@ -74,6 +83,25 @@ string.
=back
=item C<plugins> B<EXPERIMENTAL>
=over
=item B<Description>
Gets information about the plugins that are currently installed and enabled
in this Bugzilla.
=item B<Params> (none)
=item B<Returns>
A hash with a single item, C<plugins>. This points to a hash. I<That> hash
contains the names of plugins as keys, and the versions of the plugin as
values.
=back
=item C<timezone> B<EXPERIMENTAL>
=over
...
...
extensions/example/version.pl
0 → 100644
View file @
dc4fc18f
# -*- 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 Example WebService Plugin
#
# The Initial Developer of the Original Code is Everything Solved, Inc.
# Portions created by Everything Solved, Inc. are Copyright (C) 2007
# Everything Solved, Inc. All Rights Reserved.
#
# Contributor(s): Max Kanat-Alexander <mkanat@bugzilla.org>
# This script does some code to return a version number. However,
# most plugins will probably just want to return a raw string.
# To do that, the only contents of the file should be the string
# on a single line, like:
#
# '1.2.3';
use
strict
;
no
warnings
qw(void)
;
# Avoid "useless use of a constant in void context"
use
Bugzilla::
Constants
;
BUGZILLA_VERSION
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment