Bug 22832 - Require plugins to specify the methods they implement
Summary: Require plugins to specify the methods they implement
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Plugin architecture (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Testopia
URL:
Keywords:
Depends on: 24631 21073
Blocks: 23890 23171
  Show dependency treegraph
 
Reported: 2019-05-02 15:43 UTC by Tomás Cohen Arazi
Modified: 2022-10-24 15:02 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2019-05-02 15:43:31 UTC
With bug 21073, a simple plugin implementing (say) only the to_marc method generates this on the DB:

mysql> SELECT * FROM plugin_methods;
+-----------------------------------------------+-------------------------------+
| plugin_class                                  | plugin_method                 |
+-----------------------------------------------+-------------------------------+
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | _handle_control_field         |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | _version_compare              |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | abs_path                      |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | as_heavy                      |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | canonpath                     |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | catdir                        |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | catfile                       |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | configure                     |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | curdir                        |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | except                        |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | export                        |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | export_fail                   |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | export_ok_tags                |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | export_tags                   |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | export_to_level               |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | file_name_is_absolute         |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | get_metadata                  |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | get_plugin_http_path          |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | get_qualified_table_name      |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | get_template                  |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | go_home                       |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | import                        |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | install                       |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | max                           |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | mbf_dir                       |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | mbf_exists                    |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | mbf_open                      |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | mbf_path                      |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | mbf_read                      |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | mbf_validate                  |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | new                           |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | no_upwards                    |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | only                          |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | output                        |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | output_html                   |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | output_html_with_http_headers |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | output_with_http_headers      |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | path                          |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | plugins                       |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | require_version               |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | retrieve_data                 |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | rootdir                       |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | search_path                   |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | store_data                    |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | to_marc                       |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | uninstall                     |
| Koha::Plugin::Com::ByWaterSolutions::CSV2MARC | updir                         |
+-----------------------------------------------+-------------------------------+
47 rows in set (0.00 sec)

I think plugins should just expose what methods they implement that are intended to be used in Koha, not any internal method.
Comment 1 Magnus Enger 2020-05-04 11:22:47 UTC
Will the "interesting methods" always correspond to the plugin hooks that are in Koha? Or will there be cases where an "interesting method" is not in that list? If we are only looking for which plugin hooks a plugin implements, perhaps we could maintain a list of the hooks and filter the plugin_methods we have today against that list?
Comment 2 Martin Renvoize 2020-05-04 11:43:55 UTC
We have discussed the possibility of a whitelist before... currently we have not done that so we can support legacy plugins which implement additional workflows via `/cgi-bin/koha/plugins/run.pl?class=plugin_class&method=X`
Comment 3 David Cook 2020-05-04 23:31:15 UTC
(In reply to Tomás Cohen Arazi from comment #0)
> I think plugins should just expose what methods they implement that are
> intended to be used in Koha, not any internal method.

Agreed. That would make it much easier to manage plugins.