Bug 37197 - Batch patron modification from reports fails by using GET instead of POST
Summary: Batch patron modification from reports fails by using GET instead of POST
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Reports (show other bugs)
Version: Main
Hardware: All All
: P5 - low major
Assignee: Phil Ringnalda
QA Contact: Matt Blenkinsop
URL:
Keywords: regression, rel_24_05_candidate
: 37479 (view as bug list)
Depends on: 36192
Blocks: 37188 37481 37615
  Show dependency treegraph
 
Reported: 2024-06-26 14:21 UTC by Phil Ringnalda
Modified: 2024-09-11 17:56 UTC (History)
3 users (show)

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


Attachments
Bug 37197: Reports option to send to batch patron modification needs to use POST (2.62 KB, patch)
2024-06-27 03:33 UTC, Phil Ringnalda
Details | Diff | Splinter Review
Bug 37197: Reports option to send to batch patron modification needs to use POST (2.67 KB, patch)
2024-06-28 18:40 UTC, David Nind
Details | Diff | Splinter Review
Bug 37197: Reports option to send to batch patron modification needs to use POST (2.75 KB, patch)
2024-07-01 15:38 UTC, Matt Blenkinsop
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Phil Ringnalda 2024-06-26 14:21:24 UTC
When you SELECT cardnumber FROM borrowers you get a Batch operations menuitem to send the results to Patron batch modification, but because of what looks like it might be an accidental change in https://git.koha-community.org/Koha-community/Koha/commit/8a20e0cb6a0efd6b993e361d439dbb4486ba15d1 they are sent in a GET with the op show (which no longer exists) rather than a POST with cud-show.
Comment 1 Phil Ringnalda 2024-06-27 03:33:38 UTC
Created attachment 168187 [details] [review]
Bug 37197: Reports option to send to batch patron modification needs to use POST

When you have an SQL report that selects cardnumber from borrowers, you
get a menuitem to send the results to Batch patron modification. Currently
that fails with a message about no card numbers or borrowernumbers given,
because it tries to do a GET with the op show, when modborrowers.pl is
expecting a POST with the op cud-show.

Test plan:
1. Without the patch, Reports - Create from SQL - name it and paste

select cardnumber from borrowers

   in the SQL textarea and save, then Run report.
2. Above the results is a "Batch operations with 20 visible records" menu,
   choose Batch patron modification
3. Note that instead of modifying the records, you're stuck with a message
   saying "No patron card numbers or borrowernumbers given." even though
   there's a whole string of them in the URL.
4. Apply patch, refresh the page with the results (oddly, no apparent need
   to even restart_all), and choose the menuitem again, but this time with
   a successful result.
Comment 2 David Nind 2024-06-28 18:40:36 UTC
Created attachment 168287 [details] [review]
Bug 37197: Reports option to send to batch patron modification needs to use POST

When you have an SQL report that selects cardnumber from borrowers, you
get a menuitem to send the results to Batch patron modification. Currently
that fails with a message about no card numbers or borrowernumbers given,
because it tries to do a GET with the op show, when modborrowers.pl is
expecting a POST with the op cud-show.

Test plan:
1. Without the patch, Reports - Create from SQL - name it and paste

select cardnumber from borrowers

   in the SQL textarea and save, then Run report.
2. Above the results is a "Batch operations with 20 visible records" menu,
   choose Batch patron modification
3. Note that instead of modifying the records, you're stuck with a message
   saying "No patron card numbers or borrowernumbers given." even though
   there's a whole string of them in the URL.
4. Apply patch, refresh the page with the results (oddly, no apparent need
   to even restart_all), and choose the menuitem again, but this time with
   a successful result.

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 Matt Blenkinsop 2024-07-01 15:38:25 UTC
Created attachment 168322 [details] [review]
Bug 37197: Reports option to send to batch patron modification needs to use POST

When you have an SQL report that selects cardnumber from borrowers, you
get a menuitem to send the results to Batch patron modification. Currently
that fails with a message about no card numbers or borrowernumbers given,
because it tries to do a GET with the op show, when modborrowers.pl is
expecting a POST with the op cud-show.

Test plan:
1. Without the patch, Reports - Create from SQL - name it and paste

select cardnumber from borrowers

   in the SQL textarea and save, then Run report.
2. Above the results is a "Batch operations with 20 visible records" menu,
   choose Batch patron modification
3. Note that instead of modifying the records, you're stuck with a message
   saying "No patron card numbers or borrowernumbers given." even though
   there's a whole string of them in the URL.
4. Apply patch, refresh the page with the results (oddly, no apparent need
   to even restart_all), and choose the menuitem again, but this time with
   a successful result.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Comment 4 Katrin Fischer 2024-07-01 16:11:02 UTC
I am wondering if POST is the correct one here as we are not changing data but sending them to display in another tool. Why not GET and op=show?
Comment 5 Phil Ringnalda 2024-07-01 17:04:11 UTC
My bib numbers are seven digits, so &b=nnnnnnn is ten digits, and a report showing 1000 rows per page would be a query string of 10,000 characters. Well, 9,999 since the first one wouldn't have an ampersand.

I don't have any real feeling about what a true current answer to "what is the safe maximum size of a URL" would actually be, but there certainly are a lot of answers a lot smaller than that.
Comment 6 Matt Blenkinsop 2024-07-04 14:33:17 UTC
A bit of research suggests that Apache has a limit of 8177 characters (I'm assuming that Apache would be the limitation rather than the browser although this might be browser dependent).
Comment 7 Phil Ringnalda 2024-07-04 21:19:38 UTC
(In reply to Phil Ringnalda from comment #0)
> what looks like it might be an accidental change in
> https://git.koha-community.org/Koha-community/Koha/commit/
> 8a20e0cb6a0efd6b993e361d439dbb4486ba15d1 

That one probably was an accidental change. The clearly intentional one was https://git.koha-community.org/Koha-community/Koha/commit/21fa3f64c31dad23e50e633a6f51f98c8f7ade12 which did not work because it left the wrong op in the GET form in reports, and would have needed to put the multi_param('cardnumber') into a new op with a name that could take a GET.
Comment 8 Phil Ringnalda 2024-07-04 21:40:42 UTC
But if something is wrong with the semantics of a hidden textarea in a URL that ends in guided_reports.pl POSTing to modborrowers.pl, the exact same thing is wrong with an unhidden textarea in a URL that ends in modborrowers.pl POSTing to modborrowers.pl, and the same thing is wrong with batch item and record modification, and batch item and record deletion, and they should all be changed to do a GET of op=show, and they should all break when Apache returns Request URI too long. And there's no semantic difference between uploading a textarea of cardnumbers and uploading a text file of cardnumbers, so while we're writing a little JS to convert the textarea content to a query string, we should also convert the file selected for upload to a query string too.

Note that my patch *was* wrong, because I didn't see that I should have also undone the change from a hidden textarea to a bunch of hidden inputs.
Comment 9 Phil Ringnalda 2024-07-04 22:20:59 UTC
Oh, hey, we do have an example of desperately trying to stay under the Apache URL length limit, Add to list concatenates biblionumbers separated by '/' and crams them into a single query param. That can save up to 1999 characters by replacing &b= with /. If someone fixed bug 37188 by making batch patron modification only an option when borrowernumber is selected (probably rarely more than 7 digits) instead of cardnumber (14 digits in my world), then Apache would only break it for large sites, and they really ought to have someone who knows how to edit Apache's conf files.
Comment 10 Jonathan Druart 2024-07-05 14:05:25 UTC
It should be cud-show and POST for this exact limitation problem.
Comment 11 Jonathan Druart 2024-07-05 14:05:45 UTC
koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt

 95                                                 <li>
 96                                                     <a href="/cgi-bin/koha/tools/modborrowers.pl?patron_list_id=[% l.patron_list_id | uri %]&op=show">
 97                                                         <i class="fa-solid fa-pencil" aria-hidden="true"></i> Batch edit patrons
 98                                                     </a>
 99                                                 </li>


This one seems to be another problematic one.
Comment 12 Jonathan Druart 2024-07-05 14:06:12 UTC
And 

koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/patron-lists-tab.tt:                                                <a href="/cgi-bin/koha/tools/modborrowers.pl?patron_list_id=[% l.patron_list_id | uri %]&op=show">
Comment 13 Phil Ringnalda 2024-07-06 17:20:49 UTC
We have UI to batch modify patrons in a patron list that includes the patron you are checking items out to? Thanks, I hate it!

Every action you can take with a patron list, batch modify, batch delete, and print cards, is broken for the same reason: they want to GET ?list_id=1 and the op takes a cud- POST.

Do we need a new pattern for all of these, having two ops like get_a_little and cud-post_a_lot which each just get their input and call sub do_the_work? Or do we want to say that if anyone has so much data they have to POST it, then everybody has to POST even if it's just one digit they need to send?
Comment 14 Jonathan Druart 2024-07-10 13:52:59 UTC
(In reply to Phil Ringnalda from comment #13)
> We have UI to batch modify patrons in a patron list that includes the patron
> you are checking items out to? Thanks, I hate it!
> 
> Every action you can take with a patron list, batch modify, batch delete,
> and print cards, is broken for the same reason: they want to GET ?list_id=1
> and the op takes a cud- POST.
> 
> Do we need a new pattern for all of these, having two ops like get_a_little
> and cud-post_a_lot which each just get their input and call sub do_the_work?
> Or do we want to say that if anyone has so much data they have to POST it,
> then everybody has to POST even if it's just one digit they need to send?

Good question. I have never considered we could support both, that's an interesting idea.

We could indeed have "show" allowed for patron_list_id if it makes things here easier to fix.
Comment 15 Jonathan Druart 2024-07-10 14:53:12 UTC
We are doing that already for items actually

tools/batchMod.pl
209 if ($op eq "cud-show" || $op eq "show"){
Comment 16 Phil Ringnalda 2024-07-10 15:15:37 UTC
Bug 36326 comment 21 makes it hard to claim that as a precedent, though.
Comment 17 Nick Clemens (kidclamp) 2024-07-25 17:32:28 UTC
*** Bug 37479 has been marked as a duplicate of this bug. ***
Comment 18 Nick Clemens (kidclamp) 2024-07-25 17:35:01 UTC
I suggest we push forward this patch that fixes a bug - and move our discussion of how to make this consistent on to another bug
Comment 19 Martin Renvoize 2024-07-26 12:55:51 UTC
Thanks for all the hard work!

Pushed to main for the next 24.11.00 release as RM Assistant
Comment 20 Phil Ringnalda 2024-08-09 20:36:32 UTC
(In reply to Phil Ringnalda from comment #13)
> Every action you can take with a patron list, batch modify, batch delete,
> and print cards, is broken for the same reason: they want to GET ?list_id=1
> and the op takes a cud- POST.

Actually, batch delete isn't broken, I just automatically use Staff patrons whenever I need a patron and batch patron deletion won't delete Staff.

Filed bug 37612 for batch modify and bug 37614 for print cards.
Comment 21 Phil Ringnalda 2024-08-09 21:15:08 UTC
(In reply to Phil Ringnalda from comment #8)
> Note that my patch *was* wrong, because I didn't see that I should have also
> undone the change from a hidden textarea to a bunch of hidden inputs.

Filed bug 37615 for that.