Bug 41857

Summary: Suggestions table actions broken Update manager and Delete selected actions)
Product: Koha Reporter: Pedro Amorim <pedro.amorim>
Component: Architecture, internals, and plumbingAssignee: Pedro Amorim <pedro.amorim>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: baptiste.wojtkowski, david, jonathan.druart, martin.renvoize, matt.blenkinsop, pedro.amorim
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38192
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes errors that are generated when selecting a suggestion in the staff interface and: - Updating the manager for the suggestion (Update manager > [select manager] > Submit) - Deleting the suggestion (Delete selected > Submit) (Related to changes made by Bug 39721 - Remove GetSuggestion from C4/Suggestions.pm, added in Koha 26.05.)
Version(s) released in:
Circulation function:
Bug Depends on: 39721    
Bug Blocks:    
Attachments: Bug 41857: Remove suggestion
Bug 41857: Use suggesteddate_from and suggesteddate_to
Bug 41857: Only find singly suggestion by id if 'edit_form'
Bug 41857: Remove suggestion
Bug 41857: Use suggesteddate_from and suggesteddate_to
Bug 41857: Only find singly suggestion by id if 'edit_form'

Description Pedro Amorim 2026-02-16 11:52:30 UTC

    
Comment 1 Pedro Amorim 2026-02-16 11:59:26 UTC
Created attachment 193184 [details] [review]
Bug 41857: Remove suggestion

I don't understand why we need this here, but it seems to be picking up a leftover suggestion from a previous loop.
This code itself is not within a loop, so it doesnt have the hashref containing suggestiontype from suggestion.pl.
It's trying to access suggestiontype from Koha::Suggestion which causes an explosion
Comment 2 Pedro Amorim 2026-02-16 11:59:30 UTC
Created attachment 193185 [details] [review]
Bug 41857: Use suggesteddate_from and suggesteddate_to

From URL params. I believe this was an overupdate from bug 39721.

Test plan:
1) Create a new suggestion:
http://localhost:8081/cgi-bin/koha/suggestion/suggestion.pl?op=add_form&branchcode=
2) Add a title and submit.
3) From the table, select the suggesiton (check the box).
4) Click the 'submit' under 'Update manager' or 'Delete selected'.
5) Error
Comment 3 Pedro Amorim 2026-02-16 12:00:02 UTC
Stumbled upon this while rebasing bug 40504 on top of 39721.
Comment 4 Jonathan Druart 2026-02-16 14:18:29 UTC
update manager with more than one (or none) and you get a 500

DBIx::Class::ResultSet::find(): find() expects either a column/value hashref, or a list of values corresponding to the columns of the specified unique constraint 'primary' at /kohadevbox/koha/Koha/Objects.pm line 
95
 at /usr/share/perl5/DBIx/Class/Exception.pm line 77
        DBIx::Class::Exception::throw('DBIx::Class::Exception', 'find() expects either a column/value hashref, or a list of values corresponding to the columns of the specified unique constraint \'primary\'', 0) c
alled at /usr/share/perl5/DBIx/Class/Schema.pm line 1118
        DBIx::Class::Schema::throw_exception('Koha::Schema=HASH(0x63f676efab10)', 'find() expects either a column/value hashref, or a list of values corresponding to the columns of the specified unique constraint 
\'primary\'') called at /usr/share/perl5/DBIx/Class/ResultSource.pm line 2379
        DBIx::Class::ResultSource::throw_exception('DBIx::Class::ResultSource::Table=HASH(0x63f6773b6850)', 'find() expects either a column/value hashref, or a list of values corresponding to the columns of the sp
ecified unique constraint \'primary\'') called at /usr/share/perl5/DBIx/Class/ResultSet.pm line 4011
        DBIx::Class::ResultSet::throw_exception('DBIx::Class::ResultSet=HASH(0x63f6794baee0)', 'find() expects either a column/value hashref, or a list of values corresponding to the columns of the specified uniqu
e constraint \'primary\'') called at /usr/share/perl5/DBIx/Class/ResultSet.pm line 809
        DBIx::Class::ResultSet::find('DBIx::Class::ResultSet=HASH(0x63f6794baee0)', 1, 2) called at /kohadevbox/koha/Koha/Objects.pm line 95
        Koha::Objects::find('Koha::Suggestions', 1, 2) called at /kohadevbox/koha/suggestion/suggestion.pl line 105
Comment 5 Pedro Amorim 2026-02-16 14:55:54 UTC
Yes, caused by:

    $stored_suggestion = Koha::Suggestions->find(1 $input->param('suggestionid') ) if $input->param('suggestionid');

Also added in bug 39721. suggestionid may be multiple. Looking.
Comment 6 Pedro Amorim 2026-02-16 15:12:36 UTC
Created attachment 193256 [details] [review]
Bug 41857: Only find singly suggestion by id if 'edit_form'

All ops that iterate on editsuggestions can potentially have multiple suggestionid and don't need stored_suggestion
cud-update_status
cud-delete
cud-archive
cud-unarchive
cud-update_itemtype
cud-update_manager

I'm unsure if op = 'else' should also be included with edit_form
Comment 7 David Nind 2026-02-16 20:03:50 UTC
Created attachment 193268 [details] [review]
Bug 41857: Remove suggestion

I don't understand why we need this here, but it seems to be picking up a leftover suggestion from a previous loop.
This code itself is not within a loop, so it doesnt have the hashref containing suggestiontype from suggestion.pl.
It's trying to access suggestiontype from Koha::Suggestion which causes an explosion

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 David Nind 2026-02-16 20:03:52 UTC
Created attachment 193269 [details] [review]
Bug 41857: Use suggesteddate_from and suggesteddate_to

From URL params. I believe this was an overupdate from bug 39721.

Test plan:
1) Create a new suggestion:
http://localhost:8081/cgi-bin/koha/suggestion/suggestion.pl?op=add_form&branchcode=
2) Add a title and submit.
3) From the table, select the suggesiton (check the box).
4) Click the 'submit' under 'Update manager' or 'Delete selected'.
5) Error

Signed-off-by: David Nind <david@davidnind.com>
Comment 9 David Nind 2026-02-16 20:03:55 UTC
Created attachment 193270 [details] [review]
Bug 41857: Only find singly suggestion by id if 'edit_form'

All ops that iterate on editsuggestions can potentially have multiple suggestionid and don't need stored_suggestion
cud-update_status
cud-delete
cud-archive
cud-unarchive
cud-update_itemtype
cud-update_manager

I'm unsure if op = 'else' should also be included with edit_form

Signed-off-by: David Nind <david@davidnind.com>
Comment 10 David Nind 2026-02-16 20:10:23 UTC
Updated the assignee.