Bug 31785

Summary: Adding or editing library does not respect public flag
Product: Koha Reporter: Marcel de Rooy <m.de.rooy>
Component: Architecture, internals, and plumbingAssignee: Marcel de Rooy <m.de.rooy>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: arthur.suzuki, david, jonathan.druart, lucas, tomascohen, wainuiwitikapark
Version: MainKeywords: rel_22_11_candidate
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31775
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31654
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.08, 21.11.15
Attachments: Bug 31785: Fix for adding non-public library
Bug 31785: Fix for adding non-public library
Bug 31785: (follow-up) Fix modify operation too
Bug 31785: Fix for adding non-public library
Bug 31785: (follow-up) Fix modify operation too

Description Marcel de Rooy 2022-10-14 07:21:59 UTC
If you set public to No, it will still be public.
Comment 1 Marcel de Rooy 2022-10-14 07:39:32 UTC
Offending line in admin/branches:

                          : ( $_ => scalar $input->param($_) || undef )

The 0 of public becomes undef ;)
Comment 2 Marcel de Rooy 2022-10-14 07:45:03 UTC
Created attachment 141863 [details] [review]
Bug 31785: Fix for adding non-public library

The code in admin/branches.pl changed a 0 to undef which is not
desirable for booleans.
A similar fix was already present for pickup_location.
This may need a bit more thought (somewhere else!).

Test plan:
Add a new branch with pickup location No, public No.
Check.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 3 Marcel de Rooy 2022-10-14 07:45:44 UTC
Trivial: self SO
Comment 4 Marcel de Rooy 2022-10-14 07:48:14 UTC
Created attachment 141864 [details] [review]
Bug 31785: Fix for adding non-public library

The code in admin/branches.pl changed a 0 to undef which is not
desirable for booleans.
A similar fix was already present for pickup_location.
This may need a bit more thought (somewhere else!).

Test plan:
Add a new branch with pickup location No, public No.
Check.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 5 Marcel de Rooy 2022-10-14 07:49:16 UTC
Added a ^ and $ to be more safe :)
Comment 6 Marcel de Rooy 2022-10-14 09:08:51 UTC
Created attachment 141868 [details] [review]
Bug 31785: (follow-up) Fix modify operation too

Test plan:
Enable SQL strict mode (koha-conf).
Modify branch, set Public to No.
Check.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 7 Marcel de Rooy 2022-10-14 09:19:39 UTC
Strict SQL mode triggers the error on update.

[WARN] DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Column 'public' cannot be null at /usr/share/koha/Koha/Object.pm line 170
Comment 8 Marcel de Rooy 2022-10-14 09:20:21 UTC
(In reply to Marcel de Rooy from comment #7)
> Strict SQL mode triggers the error on update.
> 
> [WARN] DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception:
> DBD::mysql::st execute failed: Column 'public' cannot be null at
> /usr/share/koha/Koha/Object.pm line 170

Fixed in the follow-up
Comment 9 David Nind 2022-10-14 09:35:25 UTC
Can confirm that this now works as expected - can now edit a library and change public to 'No', and change back to 'Yes'.
Comment 10 Lucas Gass 2022-10-14 15:50:38 UTC
*** Bug 31688 has been marked as a duplicate of this bug. ***
Comment 11 Lucas Gass 2022-10-14 15:54:47 UTC
Trivial, fixes the problem, QA script is happy. Going to Pass QA.
Comment 12 Lucas Gass 2022-10-14 15:55:20 UTC
Created attachment 141897 [details] [review]
Bug 31785: Fix for adding non-public library

The code in admin/branches.pl changed a 0 to undef which is not
desirable for booleans.
A similar fix was already present for pickup_location.
This may need a bit more thought (somewhere else!).

Test plan:
Add a new branch with pickup location No, public No.
Check.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 13 Lucas Gass 2022-10-14 15:55:25 UTC
Created attachment 141898 [details] [review]
Bug 31785: (follow-up) Fix modify operation too

Test plan:
Enable SQL strict mode (koha-conf).
Modify branch, set Public to No.
Check.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 14 Tomás Cohen Arazi 2022-10-14 19:05:52 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 15 Lucas Gass 2022-12-05 20:15:08 UTC
Backported to 22.05.x for upcoming 22.05.08
Comment 16 Arthur Suzuki 2022-12-16 13:21:41 UTC
applied to 21.11 for 21.11.15
Comment 17 wainuiwitikapark 2023-03-15 00:54:50 UTC
Not backported to 21.05.x