If one tries to modify a suggestion that has no suggester you will get the following error: Can't call method "lang" on an undefined value at /usr/share/koha/lib/C4/Suggestions.pm line 506 Koha assumes that every suggestion has a borrowernumber in suggestedb.y
Created attachment 88816 [details] [review] Bug 22778: Suggestions with no "suggester" can cause errors If one tries to modify a suggestion that has no suggester you will get the following error: Can't call method "lang" on an undefined value at /usr/share/koha/lib/C4/Suggestions.pm line 506 Koha assumes that every suggestion has a borrowernumber in suggestedby Test Plan: 1) Create a suggestion with an unpopulated suggestedby 2) Attempt to modify that suggestion 3) Note the error 4) Apply this patch 5) Restart all teh things 6) Attempt to modify that suggestion 7) No error!
Oh you are not going to like this: Using index info to reconstruct a base tree... M C4/Suggestions.pm Falling back to patching base and 3-way merge... Auto-merging C4/Suggestions.pm CONFLICT (content): Merge conflict in C4/Suggestions.pm error: Failed to merge in the changes. Terribly sorry >.< Liz
Created attachment 102229 [details] [review] Bug 22778: Suggestions with no "suggester" can cause errors If one tries to modify a suggestion that has no suggester you will get the following error: Can't call method "lang" on an undefined value at /usr/share/koha/lib/C4/Suggestions.pm line 506 Koha assumes that every suggestion has a borrowernumber in suggestedby Test Plan: 1) Create a suggestion with an unpopulated suggestedby 2) Attempt to modify that suggestion 3) Note the error 4) Apply this patch 5) Restart all teh things 6) Attempt to modify that suggestion 7) No error!
I've been unable to create a suggestion without a populated suggestedby field. Even anonymous suggestions have a borrowernumber for the Anonymous patron, which I believe is correct behaviour. What is the workflow for creating a suggestion with no suggester?
Maybe try and delete the patron - I think we had a case where this caused an issue.
Created attachment 102426 [details] [review] Bug 22778: Suggestions with no "suggester" can cause errors If one tries to modify a suggestion that has no suggester you will get the following error: Can't call method "lang" on an undefined value at /usr/share/koha/lib/C4/Suggestions.pm line 506 Koha assumes that every suggestion has a borrowernumber in suggestedby Test Plan: 1) Create a suggestion with an unpopulated suggestedby 2) Attempt to modify that suggestion 3) Note the error 4) Apply this patch 5) Restart all teh things 6) Attempt to modify that suggestion 7) No error! Signed-off-by: David Roberts <david@koha-ptfs.co.uk>
(In reply to Katrin Fischer from comment #5) > Maybe try and delete the patron - I think we had a case where this caused an > issue. Thanks, yes that worked so I've signed it off. I can't help feeling however that it would be better if we prevented any users from being deleted if they had suggestions attached. This seems like an ingenious solution to a problem that should never have been allowed to happen in the first place! :-)
(In reply to David Roberts from comment #7) > (In reply to Katrin Fischer from comment #5) > > Maybe try and delete the patron - I think we had a case where this caused an > > issue. > > Thanks, yes that worked so I've signed it off. I can't help feeling however > that it would be better if we prevented any users from being deleted if they > had suggestions attached. This seems like an ingenious solution to a problem > that should never have been allowed to happen in the first place! :-) We could add a warning maybe, but I think it's not quite possible to prevent - there might be suggestions that have already been purchased/finished and the library might still want to report on them.
Can you provide tests please? What about doing that instead: - if ( $suggestion->{STATUS} ) { + if ( $suggestion->{STATUS} && $suggestion_object->suggestedby ) { That will let us hit the expected "return 1" at the end of the subroutine.
Created attachment 102581 [details] [review] Bug 22778: Suggestions with no "suggester" can cause errors If one tries to modify a suggestion that has no suggester you will get the following error: Can't call method "lang" on an undefined value at /usr/share/koha/lib/C4/Suggestions.pm line 506 Koha assumes that every suggestion has a borrowernumber in suggestedby Test Plan: 1) Create a suggestion with an unpopulated suggestedby 2) Attempt to modify that suggestion 3) Note the error 4) Apply this patch 5) Restart all teh things 6) Attempt to modify that suggestion 7) No error! Signed-off-by: David Roberts <david@koha-ptfs.co.uk>
Created attachment 102582 [details] [review] Bug 22778: Add unit test
Created attachment 102611 [details] [review] Bug 22778: Suggestions with no "suggester" can cause errors If one tries to modify a suggestion that has no suggester you will get the following error: Can't call method "lang" on an undefined value at /usr/share/koha/lib/C4/Suggestions.pm line 506 Koha assumes that every suggestion has a borrowernumber in suggestedby Test Plan: 1) Create a suggestion with an unpopulated suggestedby 2) Attempt to modify that suggestion 3) Note the error 4) Apply this patch 5) Restart all teh things 6) Attempt to modify that suggestion 7) No error! Signed-off-by: David Roberts <david@koha-ptfs.co.uk> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 102612 [details] [review] Bug 22778: Add unit test Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Amended patch: replace "suggestor" with "suggester"
Nice work everyone! Pushed to master for 20.05
backported to 19.11.x for 19.11.06
backported to 19.05.x for 19.05.11