Bug 37163

Summary: Fix the redirect after deleting a tag from an authority framework to load the right page
Product: Koha Reporter: Phil Ringnalda <phil>
Component: System AdministrationAssignee: Phil Ringnalda <phil>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: david, fridolin.somers, gmcharlt, lucas, samalau, wainuiwitikapark
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37161
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37152
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37162
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes the redirect after deleting a tag from an authority framework. After confirming the deletion of a tag, you are now returned to where you were in the list of tags for the authority type, instead of tag 000 (this now matches the behavour when deleting tags for a MARC framework - see bug 37161).
Version(s) released in:
24.11.00,24.05.02,23.11.07
Circulation function:
Bug Depends on: 918    
Bug Blocks:    
Attachments: Bug 37163: Fix the redirect after deleting a tag from an authority framework to load the right page
Bug 37163: Fix the redirect after deleting a tag from an authority framework to load the right page
Bug 37163: Fix the redirect after deleting a tag from an authority framework to load the right page

Description Phil Ringnalda 2024-06-22 00:43:13 UTC
https://git.koha-community.org/Koha-community/Koha/src/commit/36c4d315c8b4bac116377d7fac4d9e51414c7f80/admin/auth_tag_structure.pl#L160 attempts to send you back to the page where you were when you deleted a tag from an authority framework, but since the previous line sets  my $tagfield = $input->param('tagfield'); when the actual param is 'searchfield' ('tagfield' is only set when you are creating a new tag, editing tags misuses 'searchfield' whether or not you searched for it) so it fails.

Whether or not that redirect is the right thing to do is bug 37162 once bug 37161 decides what approach to use, but those may or may not go back through every supported version since they probably depend on the CSRF changes, and this has been busted since bug 918 landed in 2009.
Comment 1 Phil Ringnalda 2024-06-22 01:08:20 UTC
Created attachment 167999 [details] [review]
Bug 37163: Fix the redirect after deleting a tag from an authority framework to load the right page

When you delete a tag from an authority framework, we intend to redirect you
right back to where you were, on the same page of tags, but because we pick
the wrong variable to set searchfield in the URL, we send you to the first
page instead.

Test plan:
1. Without the patch, Administration - Authority types - in the row for
   CHRON_TERM Actions menu, MARC Structure
2. In the Search for tag: input, type 092 and hit Enter
3. In the row for 092, Actions menu, Delete, in the page that loads click
   Yes, delete
4. In the page you are redirected to, note that you are at Tag 000, and the
   URL is ?searchfield=&authtypecode=CHRON_TERM
5. Apply patch, restart_all
6. Type 092 and hit Enter, Actions menu for the 093 row, Delete, Yes, delete
7. Note that now you have gone to the page where 093 used to be, because
   the URL is ?searchfield=092&authtypecode=CHRON_TERM and you can just
   keep deleting 09x tags one after another
Comment 2 Phil Ringnalda 2024-06-22 01:10:37 UTC
Well, the URL is ?searchfield=093, not 092, since searchfield is intentionally the one you deleted, not what was in the search field at the time. That was just a typo.
Comment 3 Lucas Gass (lukeg) 2024-06-24 14:47:53 UTC
Phil,

Without this patch applied I am unable to recreate the problem described in your test plan.
Comment 4 Phil Ringnalda 2024-06-24 15:12:33 UTC
Interesting. That means you have $input->param('tagfield') defined as 092 when you submit a form with four params: csrf_token, op, authtypecode, and searchfield.

How?
Comment 5 Sam Lau 2024-06-24 16:44:46 UTC
I am recreating this problem and applying the patch fixes the issue as described.
Comment 6 Sam Lau 2024-06-24 16:45:38 UTC
Created attachment 168031 [details] [review]
Bug 37163: Fix the redirect after deleting a tag from an authority framework to load the right page

When you delete a tag from an authority framework, we intend to redirect you
right back to where you were, on the same page of tags, but because we pick
the wrong variable to set searchfield in the URL, we send you to the first
page instead.

Test plan:
1. Without the patch, Administration - Authority types - in the row for
   CHRON_TERM Actions menu, MARC Structure
2. In the Search for tag: input, type 092 and hit Enter
3. In the row for 092, Actions menu, Delete, in the page that loads click
   Yes, delete
4. In the page you are redirected to, note that you are at Tag 000, and the
   URL is ?searchfield=&authtypecode=CHRON_TERM
5. Apply patch, restart_all
6. Type 092 and hit Enter, Actions menu for the 093 row, Delete, Yes, delete
7. Note that now you have gone to the page where 093 used to be, because
   the URL is ?searchfield=092&authtypecode=CHRON_TERM and you can just
   keep deleting 09x tags one after another

Signed-off-by: Sam Lau <samalau@gmail.com>
Comment 7 Nick Clemens (kidclamp) 2024-06-25 22:46:21 UTC
Created attachment 168110 [details] [review]
Bug 37163: Fix the redirect after deleting a tag from an authority framework to load the right page

When you delete a tag from an authority framework, we intend to redirect you
right back to where you were, on the same page of tags, but because we pick
the wrong variable to set searchfield in the URL, we send you to the first
page instead.

Test plan:
1. Without the patch, Administration - Authority types - in the row for
   CHRON_TERM Actions menu, MARC Structure
2. In the Search for tag: input, type 092 and hit Enter
3. In the row for 092, Actions menu, Delete, in the page that loads click
   Yes, delete
4. In the page you are redirected to, note that you are at Tag 000, and the
   URL is ?searchfield=&authtypecode=CHRON_TERM
5. Apply patch, restart_all
6. Type 092 and hit Enter, Actions menu for the 093 row, Delete, Yes, delete
7. Note that now you have gone to the page where 093 used to be, because
   the URL is ?searchfield=092&authtypecode=CHRON_TERM and you can just
   keep deleting 09x tags one after another

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 8 Katrin Fischer 2024-06-27 09:53:06 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 9 Lucas Gass (lukeg) 2024-07-18 20:25:54 UTC
Backported to 24.05.x for upcoming 24.05.02
Comment 10 Fridolin Somers 2024-07-19 09:43:46 UTC
Pushed to 23.11.x for 23.11.07
Comment 11 Wainui Witika-Park 2024-09-17 03:15:35 UTC
Not backporting to 23.05 unless requested