Closed Bug 617012 Opened 15 years ago Closed 15 years ago

Allow extensions to add new Jobs

Categories

(Bugzilla :: Extensions, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 4.2

People

(Reporter: gerv, Assigned: gerv)

Details

Attachments

(1 file, 2 obsolete files)

Currently, adding a new Job requires editing JOB_MAP in JobQueue.pm. We should allow extensions to add to this list, probably via the usual method of mediating access via a getter function, and putting the hook call into that function, passing a reference to the list. Gerv
Agreed, that sounds reasonable.
Attached patch Patch v.1 (obsolete) — Splinter Review
Assignee: extensions → gerv
Status: NEW → ASSIGNED
Attachment #496501 - Flags: review?(mkanat)
Comment on attachment 496501 [details] [diff] [review] Patch v.1 Thanks for this! :-) >=== modified file 'Bugzilla/Hook.pm' >+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. Make sure to insert line breaks so that these lines aren't longer than 80 chars. >+=item C<job_map> - The job map hash. Ah, specifically describe what the keys and values are. >=== modified file 'Bugzilla/JobQueue.pm' >+sub get_job_map { >+ my $job_map = JOB_MAP; >+ Bugzilla::Hook::process('job_map', { job_map => $job_map }); >+ return $job_map; >+} It'd be nice to cache this in Bugzilla->request_cache or in $self so that we don't have to run the hook every time JOB_MAP is needed. Otherwise, looks good. :-) I like that you updated the error message too, that was a good idea.
Attachment #496501 - Flags: review?(mkanat) → review-
Attached patch Patch v.2 (obsolete) — Splinter Review
Review comments addressed. Gerv
Attachment #496501 - Attachment is obsolete: true
Attachment #500170 - Flags: review?(mkanat)
Comment on attachment 500170 [details] [diff] [review] Patch v.2 >+sub get_job_map { I'd rather just see it called job_map, and be called as a class method (although the manner of calling it doesn't technically matter, since it doesn't use $class or $self). The r- is because this hook needs example code.
Attachment #500170 - Flags: review?(mkanat) → review-
Attached patch Patch v.3Splinter Review
Review comments addressed. Gerv
Attachment #500170 - Attachment is obsolete: true
Attachment #500794 - Flags: review?(mkanat)
Comment on attachment 500794 [details] [diff] [review] Patch v.3 Looks great. :-)
Attachment #500794 - Flags: review?(mkanat) → review+
Flags: approval+
Target Milestone: --- → Bugzilla 4.2
Committing to: bzr+ssh://bzr.mozilla.org/bugzilla/trunk/ modified Bugzilla/JobQueue/Runner.pm modified extensions/Example/Extension.pm modified Bugzilla/JobQueue.pm modified template/en/default/global/code-error.html.tmpl modified Bugzilla/Hook.pm Committed revision 7645. Gerv
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: