SA Bugzilla – Bug 5243
need a way to specify plugin call order
Last modified: 2006-12-15 09:00:48 UTC
Right now, if plugin A wishes to ensure that its finish_parsing_end method (for example) is called before plugin B's, there's no way to do that. We should provide a way. I'm not sure how, exactly, but first glance suggests something like this: sub new { ... boilerplate ... $self->register_method_priority('finish_parsing_end', 200); } in other words an API on the Plugin.pm object allowing a plugin implementation to specify priority values at construction time. there may be a better way, of course.
I'm thinking about doing this for 3.2.0 since it's pretty important for pluginability...
I hate to piggyback, but while you're in that part of the code how about adding an option to the call plugin method that says some plugin MUST run and if not die. That way we can force at least one plugin to implement a hook. There might be another bug opened for this already.
: jm 116...; svn commit -m "bug 5243: add Plugin::register_method_priority() API, allowing plugins to control the relative ordering of plugin callbacks relative to other plugins' implementations" lib/Mail/SpamAssassin/Plugin.pm lib/Mail/SpamAssassin/PluginHandler.pm t/data/testplugin2.pm t/plugin_priorities.t MANIFEST Sending MANIFEST Sending lib/Mail/SpamAssassin/Plugin.pm Sending lib/Mail/SpamAssassin/PluginHandler.pm Adding t/data/testplugin2.pm Adding t/plugin_priorities.t Transmitting file data ..... Committed revision 487586. let's see about the other request ;)
Michael: it looks like that can be done without adding a new API as follows. instead of: $self->{main}->call_plugins ("check_main", { permsgstatus => $self }, required => 1); [or whatever] use: if (!$self->{main}->have_plugin("check_main")) { die "no implementation found for 'check_main'!"; } $self->{main}->call_plugins ("check_main", { permsgstatus => $self }); have_plugin() already exists. I think I prefer the latter anyway, since it allows the caller to decide what action to take if 'check_main' is unimplemented by any plugin. given that, I'll mark this as FIXED; reopen if you'd prefer to see a new API instead.
Nah, that works for me, thanks.