Bug 39540

Summary: Add a warning in the circ rules page if a plugin overrides rules
Product: Koha Reporter: Tomás Cohen Arazi (tcohen) <tomascohen>
Component: Plugin architectureAssignee: Raphael Straub <raphael.straub>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: clemens.tubach, michael.skarupianski, michaela.sieber, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: Sponsored Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 39405    
Bug Blocks:    
Attachments: Bug 39540: Add a warning to the circulation rules page if CalcFine is overwritten.
Bug 39540: Add a warning to the circulation rules page if CalcFine is overwritten.
Bug 39540: Add a warning to the circulation rules page if CalcFine is overwritten.
Bug 39540: Add a warning to the circulation rules page if CalcFine is overwritten.

Description Tomás Cohen Arazi (tcohen) 2025-04-03 08:23:09 UTC
Bug 39405 introduces a way for plugins to override Koha's circulation rules-defined calculation. This can be misleading for users looking at the circulation rules matrix but getting different results than expected.

There should be some visual sign the rules they are looking at, might not be effective, and the plugin in question should be mentioned.
Comment 1 Raphael Straub 2025-04-03 10:11:48 UTC
Created attachment 180487 [details] [review]
Bug 39540: Add a warning to the circulation rules page if CalcFine is overwritten.

This patch adds a warning to the "Circulation and fine rules" page in
"Koha administration" if there is an enabled plugin that implements the
overwrite_calc_fine plugin hook.

To test:
1) Apply the patch.
2) In your browser go to
   /cgi-bin/koha/admin/smart-rules.pl
   and check that there is no warning on the top of the page.
3) Install a plugin that implements overwrite_calc_fine.
4) Reload /cgi-bin/koha/admin/smart-rules.pl and check
   that now there is a warning that displays the installed
   plugin's name.

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Comment 2 Tomás Cohen Arazi (tcohen) 2025-04-03 12:18:24 UTC
The code is correct. But could you please just add the template variable inside the IF? It would make the code more concise and simpler to track to. The patch wouldn't need to change so many files for tidying the structure too.

Something like:

```perl
if ( C4::Context->config("enable_plugins") ) {
    $template->param( overwrite_calc_fine_plugins =>  [ Koha::Plugins->new->GetPlugins(
        {
            method => 'overwrite_calc_fine',
        }
    ) ];
}
```

Thanks!
Comment 3 Raphael Straub 2025-04-03 12:55:17 UTC
Created attachment 180503 [details] [review]
Bug 39540: Add a warning to the circulation rules page if CalcFine is overwritten.

This patch adds a warning to the "Circulation and fine rules" page in
"Koha administration" if there is an enabled plugin that implements the
overwrite_calc_fine plugin hook.

To test:
1) Apply the patch.
2) In your browser go to
   /cgi-bin/koha/admin/smart-rules.pl
   and check that there is no warning on the top of the page.
3) Install a plugin that implements overwrite_calc_fine.
4) Reload /cgi-bin/koha/admin/smart-rules.pl and check
   that now there is a warning that displays the installed
   plugin's name.

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Comment 4 Raphael Straub 2025-04-03 12:57:12 UTC
(In reply to Tomás Cohen Arazi (tcohen) from comment #2)
> The code is correct. But could you please just add the template variable
> inside the IF? It would make the code more concise and simpler to track to.
> The patch wouldn't need to change so many files for tidying the structure
> too.
Yes, this is better. The updated patch is attached.
Comment 5 Raphael Straub 2025-04-03 13:02:21 UTC
Created attachment 180513 [details] [review]
Bug 39540: Add a warning to the circulation rules page if CalcFine is overwritten.

This patch adds a warning to the "Circulation and fine rules" page in
"Koha administration" if there is an enabled plugin that implements the
overwrite_calc_fine plugin hook.

To test:
1) Apply the patch.
2) In your browser go to
   /cgi-bin/koha/admin/smart-rules.pl
   and check that there is no warning on the top of the page.
3) Install a plugin that implements overwrite_calc_fine.
4) Reload /cgi-bin/koha/admin/smart-rules.pl and check
   that now there is a warning that displays the installed
   plugin's name.

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Comment 6 Raphael Straub 2025-04-03 13:12:03 UTC
Created attachment 180518 [details] [review]
Bug 39540: Add a warning to the circulation rules page if CalcFine is overwritten.

This patch adds a warning to the "Circulation and fine rules" page in
"Koha administration" if there is an enabled plugin that implements the
overwrite_calc_fine plugin hook.

To test:
1) Apply the patch.
2) In your browser go to
   /cgi-bin/koha/admin/smart-rules.pl
   and check that there is no warning on the top of the page.
3) Install a plugin that implements overwrite_calc_fine.
4) Reload /cgi-bin/koha/admin/smart-rules.pl and check
   that now there is a warning that displays the installed
   plugin's name.

Sponsored-by: Karlsruhe Institute of Technology (KIT)