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
f6a3f831
Commit
f6a3f831
authored
Jan 05, 2011
by
Gervase Markham
Committed by
Gervase Markham
Jan 05, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow extensions to add new Jobs. r,a=mkanat.
https://bugzilla.mozilla.org/show_bug.cgi?id=617012
parent
237e21f0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
3 deletions
+45
-3
Hook.pm
Bugzilla/Hook.pm
+17
-0
JobQueue.pm
Bugzilla/JobQueue.pm
+11
-1
Runner.pm
Bugzilla/JobQueue/Runner.pm
+1
-1
Extension.pm
extensions/Example/Extension.pm
+14
-0
code-error.html.tmpl
template/en/default/global/code-error.html.tmpl
+2
-1
No files found.
Bugzilla/Hook.pm
View file @
f6a3f831
...
...
@@ -730,6 +730,23 @@ database when run.
=back
=head2 job_map
Bugzilla has a system - L<Bugzilla::JobQueue> - for running jobs
asynchronously, if the administrator has set it up. This hook allows the
addition of mappings from job names to handler classes, so an extension can
fire off jobs.
Params:
=over
=item C<job_map> - The job map hash. Key: the name of the job, as should be
passed to Bugzilla->job_queue->insert(). Value: the name of the Perl module
which implements the task (an instance of L<TheSchwartz::Worker>).
=back
=head2 mailer_before_send
Called right before L<Bugzilla::Mailer> sends a message to the MTA.
...
...
Bugzilla/JobQueue.pm
View file @
f6a3f831
...
...
@@ -35,6 +35,16 @@ use constant JOB_MAP => {
send_mail
=>
'Bugzilla::Job::Mailer'
,
};
sub
job_map
{
if
(
!
defined
(
Bugzilla
->
request_cache
->
{
job_map
}))
{
my
$job_map
=
JOB_MAP
;
Bugzilla::Hook::
process
(
'job_map'
,
{
job_map
=>
$job_map
});
Bugzilla
->
request_cache
->
{
job_map
}
=
$job_map
;
}
return
Bugzilla
->
request_cache
->
{
job_map
};
}
sub
new
{
my
$class
=
shift
;
...
...
@@ -69,7 +79,7 @@ sub insert {
my
$self
=
shift
;
my
$job
=
shift
;
my
$mapped_job
=
JOB_MAP
->
{
$job
};
my
$mapped_job
=
Bugzilla::
JobQueue
->
job_map
()
->
{
$job
};
ThrowCodeError
(
'jobqueue_no_job_mapping'
,
{
job
=>
$job
})
if
!
$mapped_job
;
unshift
(
@_
,
$mapped_job
);
...
...
Bugzilla/JobQueue/Runner.pm
View file @
f6a3f831
...
...
@@ -201,7 +201,7 @@ sub gd_run {
my
$jq
=
Bugzilla
->
job_queue
();
$jq
->
set_verbose
(
$self
->
{
debug
});
foreach
my
$module
(
values
%
{
Bugzilla::JobQueue
::
JOB_MAP
()
})
{
foreach
my
$module
(
values
%
{
Bugzilla::
JobQueue
->
job_map
()
})
{
eval
"use $module"
;
$jq
->
can_do
(
$module
);
}
...
...
extensions/Example/Extension.pm
View file @
f6a3f831
...
...
@@ -386,6 +386,20 @@ sub install_before_final_checks {
print
"Install-before_final_checks hook\n"
unless
$args
->
{
silent
};
}
sub
job_map
{
my
(
$self
,
$args
)
=
@_
;
my
$job_map
=
$args
->
{
job_map
};
# This adds the named class (an instance of TheSchwartz::Worker) as a
# handler for when a job is added with the name "some_task".
$job_map
->
{
'some_task'
}
=
'Bugzilla::Extension::Example::Job::SomeClass'
;
# Schedule a job like this:
# my $queue = Bugzilla->job_queue();
# $queue->insert('some_task', { some_parameter => $some_variable });
}
sub
mailer_before_send
{
my
(
$self
,
$args
)
=
@_
;
...
...
template/en/default/global/code-error.html.tmpl
View file @
f6a3f831
...
...
@@ -304,7 +304,8 @@
[% ELSIF error == "jobqueue_no_job_mapping" %]
<code>Bugzilla::JobQueue</code> has not been configured to handle
the job "[% job FILTER html %]". You need to add this job type
to the <code>JOB_MAP</code> constant in <code>Bugzilla::JobQueue</code>.
to the <code>JOB_MAP</code> constant in <code>Bugzilla::JobQueue</code>,
perhaps by using the 'job_map' hook.
[% ELSIF error == "ldap_bind_failed" %]
Failed to bind to the LDAP server. The error message was:
...
...
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