From 3acf92064e17b76f37a3ada133b257bc3febc2ac Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Thu, 8 May 2008 03:27:26 +0000 Subject: [PATCH] Bug 396243: Allow extensions (aka plugins) to extend the WebService interface - Patch by Max Kanat-Alexander r=ghendricks a=mkanat --- Bugzilla/Hook.pm | 35 ++++++++++++++++++++++++++++++++++- xmlrpc.cgi | 6 ++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm index 8ce2d4bd13..90ac16237d 100644 --- a/Bugzilla/Hook.pm +++ b/Bugzilla/Hook.pm @@ -59,7 +59,7 @@ __END__ =head1 NAME -Bugzilla::Hook - Extendible extension hooks for Bugzilla code +Bugzilla::Hook - Extendable extension hooks for Bugzilla code =head1 SYNOPSIS @@ -190,3 +190,36 @@ definitions. F will automatically add these tables to the database when run. =back + +=head2 webservice + +This hook allows you to add your own modules to the WebService. (See +L.) + +Params: + +=over + +=item C + +A hashref that you can specify the names of your modules and what Perl +module handles the functions for that module. (This is actually sent to +L. You can see how that's used in F.) + +The Perl module name must start with C +(replace C with the name of your extension). The C +declaration inside that module must also start with +C in that module's code. + +Example: + + $dispatch->{Example} = "extensions::example::lib::Example"; + +And then you'd have a module F + +It's recommended that all the keys you put in C start with the +name of your extension, so that you don't conflict with the standard Bugzilla +WebService functions (and so that you also don't conflict with other +plugins). + +=back diff --git a/xmlrpc.cgi b/xmlrpc.cgi index c17cab86c3..7682b20f54 100755 --- a/xmlrpc.cgi +++ b/xmlrpc.cgi @@ -20,6 +20,7 @@ use lib qw(.); use Bugzilla; use Bugzilla::Constants; +use Bugzilla::Hook; # Use an eval here so that runtests.pl accepts this script even if SOAP-Lite # is not installed. @@ -29,11 +30,16 @@ $@ && ThrowCodeError('soap_not_installed'); Bugzilla->usage_mode(Bugzilla::Constants::USAGE_MODE_WEBSERVICE); +my %hook_dispatch; +Bugzilla::Hook::process('webservice', { dispatch => \%hook_dispatch }); +local @INC = (bz_locations()->{extensionsdir}, @INC); + my $response = Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI ->dispatch_with({'Bugzilla' => 'Bugzilla::WebService::Bugzilla', 'Bug' => 'Bugzilla::WebService::Bug', 'User' => 'Bugzilla::WebService::User', 'Product' => 'Bugzilla::WebService::Product', + %hook_dispatch }) ->on_action(\&Bugzilla::WebService::handle_login) ->handle; -- 2.47.2