Bug 34080

Summary: Updating suggestion status can result in 500 error
Product: Koha Reporter: Kyle M Hall (khall) <kyle>
Component: AcquisitionsAssignee: Lucas Gass (lukeg) <lucas>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: csq, lucas, martin.renvoize, mchen, pm
Version: MainKeywords: rel_22_11_candidate, rel_23_05_candidate
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34601
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00,23.05.02,22.11.08
Circulation function:
Bug Depends on: 33322    
Bug Blocks:    
Attachments: Bug 34080 - Updating suggestion status can result in 500 error
Bug 34080: Make suggestions_batch_ops a class
Bug 34080: Make suggestions_batch_ops a class
Bug 34080: Make suggestions_batch_ops a class

Description Kyle M Hall (khall) 2023-06-21 14:49:57 UTC
Sometimes using "Mark selection as" to update a suggestions can result in a 500 error with the logged error:

DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'suggestion_itemtype' in 'where clause' at /usr/share/koha/lib/Koha/Objects.pm line 394

It appears that the search params are built from *all* the form fields and then some form fields are removed from the hashref, but not all ( hence the error ).
Comment 1 Kyle M Hall (khall) 2023-06-21 14:51:37 UTC
Created attachment 152524 [details] [review]
Bug 34080 - Updating suggestion status can result in 500 error

Sometimes using "Mark selection as" to update a suggestions can result in a 500 error with the logged error:

DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'suggestion_itemtype' in 'where clause' at /usr/share/koha/lib/Koha/Objects.pm line 394

It appears that the search params are built from *all* the form fields and then some form fields are removed from the hashref, but not all ( hence the error ).
Comment 2 Lucas Gass (lukeg) 2023-06-22 21:27:29 UTC
This patch stops the 500 error from occurring. However, with it applied I am unable to switch the status of suggestions.
Comment 3 Lucas Gass (lukeg) 2023-06-23 15:11:33 UTC
To recreate:

1. Make some suggestions with different statuses. 
2. Try moving some suggestion to different statuses. 
3. Going from PENDING to another status works fine.
4. Moving from other status (REJECTED, ORDERED, etc ) will cause a 500 error.
Comment 4 Lucas Gass (lukeg) 2023-06-23 15:13:08 UTC
The suggestions_batch_ops div is repeated and therefore should be a class not and an ID.
Comment 5 Lucas Gass (lukeg) 2023-06-23 15:14:53 UTC
Created attachment 152643 [details] [review]
Bug 34080: Make suggestions_batch_ops a class

To test:
1. Make some suggestions with different statuses.
2. Try moving some suggestion to different statuses.
3. Going from PENDING to another status works fine.
4. Moving from other status (REJECTED, ORDERED, etc ) will cause a 500 error.
5. Apply patch
6. Try 2 - 4 again, no more 500 errors, yay!
Comment 6 Lucas Gass (lukeg) 2023-06-23 15:15:44 UTC
Marked as major because this effects libraries ability to manage purchase suggestions.
Comment 7 Sam Lau 2023-06-23 15:21:18 UTC
Created attachment 152644 [details] [review]
Bug 34080: Make suggestions_batch_ops a class

To test:
1. Make some suggestions with different statuses.
2. Try moving some suggestion to different statuses.
3. Going from PENDING to another status works fine.
4. Moving from other status (REJECTED, ORDERED, etc ) will cause a 500 error.
5. Apply patch
6. Try 2 - 4 again, no more 500 errors, yay!

Signed-off-by: Sam Lau <samalau@gmail.com>
Comment 8 Martin Renvoize (ashimema) 2023-06-23 15:27:47 UTC
Created attachment 152645 [details] [review]
Bug 34080: Make suggestions_batch_ops a class

To test:
1. Make some suggestions with different statuses.
2. Try moving some suggestion to different statuses.
3. Going from PENDING to another status works fine.
4. Moving from other status (REJECTED, ORDERED, etc ) will cause a 500 error.
5. Apply patch
6. Try 2 - 4 again, no more 500 errors, yay!

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 9 Martin Renvoize (ashimema) 2023-06-23 15:28:20 UTC
Trivial fix works as expected.. Passing QA
Comment 10 Tomás Cohen Arazi (tcohen) 2023-06-26 14:41:33 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 11 Patrick 2023-07-12 13:04:18 UTC
Is this bug going to be backported to 22.11?
Comment 12 Martin Renvoize (ashimema) 2023-07-17 14:41:41 UTC
Thanks for all the hard work!

Pushed to 23.05.x for the next release
Comment 13 Pedro Amorim 2023-07-18 11:55:20 UTC
Nice work everyone!

Pushed to 22.11.x for next release