Bug 24244

Summary: Cannot create suggestion with branch set to 'Any'
Product: Koha Reporter: Nick Clemens <nick>
Component: AcquisitionsAssignee: Nick Clemens <nick>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: bdaeuber, jonathan.druart, joonas.kylmala, katrin.fischer, lucas
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24327
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00
Bug Depends on: 22368, 22907    
Bug Blocks: 7047    
Attachments: Bug 24244: Send null instead of empty string if branch not set
Bug 24244: Add test
Bug 24244: Send null instead of empty string if branch not set
Bug 24244: Add test
Bug 24244: Send null instead of empty string if branch not set

Description Nick Clemens 2019-12-13 19:56:37 UTC
There is a foreign key constraint, we get an internal server error when trying to save branchcode 'Any' = ''
Comment 1 Nick Clemens 2019-12-13 20:01:34 UTC
Created attachment 96284 [details] [review]
Bug 24244: Send null instead of empty string if branch not set
Comment 2 Jonathan Druart 2019-12-15 11:45:39 UTC
Created attachment 96293 [details] [review]
Bug 24244: Add test

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 3 Jonathan Druart 2019-12-15 11:45:42 UTC
Created attachment 96294 [details] [review]
Bug 24244: Send null instead of empty string if branch not set

Fix NewSuggestion if branchcode is passed with an empty string.
Error was "Broken FK constraint"

Test plan:
Create a new suggestion, select "any" for the library.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 4 Joonas Kylmälä 2019-12-20 15:20:49 UTC
After this change the purchase suggestion would not be shown in the list at </cgi-bin/koha/suggestion/suggestion.pl>. So I would like to see a patch that handles these any library suggestions before we merge this otherwise I think we are left with a even worse situation where we have patrons submitting suggestions successfully" but then the librarians never knowing about them.
Comment 5 Nick Clemens 2019-12-20 15:41:35 UTC
(In reply to Joonas Kylmälä from comment #4)
> After this change the purchase suggestion would not be shown in the list at
> </cgi-bin/koha/suggestion/suggestion.pl>. So I would like to see a patch
> that handles these any library suggestions before we merge this otherwise I
> think we are left with a even worse situation where we have patrons
> submitting suggestions successfully" but then the librarians never knowing
> about them.

This is a regression - in the past we could create these suggestions and they have never been shown by default.

You should be able to see them by opening the Acquisition information filter and setting library to Any

Making that more obvious is a separate bug
Comment 6 Katrin Fischer 2019-12-22 10:34:09 UTC
It appears to fix the staff side, but we still got big trouble in the OPAC:
- Activate anonymous suggestions for the OPAC
- Place a suggestion while logged out
- Boom!

Broken FK constraint at /usr/share/perl5/Exception/Class/Base.pm line 88

Leaving this bug right now as I think we could add the important OPAC (end users!) fix into this one.
Comment 7 Jonathan Druart 2019-12-23 12:34:02 UTC
(In reply to Katrin Fischer from comment #6)
> It appears to fix the staff side, but we still got big trouble in the OPAC:
> - Activate anonymous suggestions for the OPAC
> - Place a suggestion while logged out
> - Boom!
> 
> Broken FK constraint at /usr/share/perl5/Exception/Class/Base.pm line 88

It works for me.
Comment 8 Katrin Fischer 2019-12-23 12:42:04 UTC
(In reply to Jonathan Druart from comment #7)
> (In reply to Katrin Fischer from comment #6)
> > It appears to fix the staff side, but we still got big trouble in the OPAC:
> > - Activate anonymous suggestions for the OPAC
> > - Place a suggestion while logged out
> > - Boom!
> > 
> > Broken FK constraint at /usr/share/perl5/Exception/Class/Base.pm line 88
> 
> It works for me.

Strange :( I can retest, but thought I had made sure yesterday to restart everything.
Comment 9 Katrin Fischer 2020-01-02 07:02:11 UTC
(In reply to Katrin Fischer from comment #8)
> (In reply to Jonathan Druart from comment #7)
> > (In reply to Katrin Fischer from comment #6)
> > > It appears to fix the staff side, but we still got big trouble in the OPAC:
> > > - Activate anonymous suggestions for the OPAC
> > > - Place a suggestion while logged out
> > > - Boom!
> > > 
> > > Broken FK constraint at /usr/share/perl5/Exception/Class/Base.pm line 88
> > 
> > It works for me.
> 
> Strange :( I can retest, but thought I had made sure yesterday to restart
> everything.

I still see the error, double checked that I had the patches applied and 'restart_all' was done before testing. I think the problem is, that I hadn't set an Anonymous patron, it was still the default of 0. - Not sure if this is a bug we need to fix. Signing off now.
Comment 10 Katrin Fischer 2020-01-02 07:03:35 UTC
Created attachment 96728 [details] [review]
Bug 24244: Add test

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 11 Katrin Fischer 2020-01-02 07:03:38 UTC
Created attachment 96729 [details] [review]
Bug 24244: Send null instead of empty string if branch not set

Fix NewSuggestion if branchcode is passed with an empty string.
Error was "Broken FK constraint"

Test plan:
Create a new suggestion, select "any" for the library.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 12 Katrin Fischer 2020-01-02 07:04:32 UTC
> I still see the error, double checked that I had the patches applied and
> 'restart_all' was done before testing. I think the problem is, that I hadn't
> set an Anonymous patron, it was still the default of 0. - Not sure if this
> is a bug we need to fix. Signing off now.

... or if we want to, fix separately as the issue seems to be a different constraint?
Comment 13 Jonathan Druart 2020-01-02 10:37:49 UTC
(In reply to Katrin Fischer from comment #6)
> It appears to fix the staff side, but we still got big trouble in the OPAC:
> - Activate anonymous suggestions for the OPAC
> - Place a suggestion while logged out
> - Boom!
> 
> Broken FK constraint at /usr/share/perl5/Exception/Class/Base.pm line 88

Opened bug 24327.
Comment 14 Martin Renvoize 2020-01-02 12:19:22 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 15 Lucas Gass 2020-01-15 18:23:11 UTC
pushed to 19.11.x for 19.11.02
Comment 16 Lucas Gass 2020-01-15 18:26:59 UTC
backported to 19.05.x for 19.05.07