Bug 20580

Summary: create_superlibrarian.pl should accept parameters
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Marcel de Rooy <m.de.rooy>
Severity: normal    
Priority: P5 - low CC: katrin.fischer, m.de.rooy, martin.renvoize, mtompset
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20590
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 20489    
Attachments: Bug 20580: Make create_superlibrarian.pl accept parameters
Bug 20580: Make create_superlibrarian.pl accept parameters

Description Jonathan Druart 2018-04-13 13:38:52 UTC
create_superlibrarian.pl should not create a koha/koha (42) patron but accept parameters instead.
Comment 1 Jonathan Druart 2018-04-16 15:34:36 UTC
Created attachment 74244 [details] [review]
Bug 20580: Make create_superlibrarian.pl accept parameters

So far this script does not accept parameters and create a koha/koha
superlibrarian
This patch makes it accept parameters to create a customized
superlibrarian patrons.

Test plan:
Use the script with valid and invalid paramters and confirm that it
works as expected.

Note: A cryptic "Invalid parameter passed" error is raised when the
categorycode is not valid. Better error handling must be provided but
Koha::Exceptions seems to be enhancement (see related bug reports).
Comment 2 Mark Tompsett 2018-04-18 01:56:13 UTC
reset_all
kshell
./misc/devel/create_superlibrarian.pl --user admin --password admin --branchcode CPL --categorycode S --cardnumber SEE_THIS_BREAKS

A new user is added, but the userid isn't admin. In my test case it was 4. Ran it 2 more times: 5 and 6. This case needs to be reported and/or prevented. If the userid exists, perhaps a nice warning and either die, or spit out the new userid.

Otherwise, it works great in "normal" circumstances.
Comment 3 Jonathan Druart 2018-04-18 13:49:18 UTC
(In reply to M. Tompsett from comment #2)
> reset_all
> kshell
> ./misc/devel/create_superlibrarian.pl --user admin --password admin
> --branchcode CPL --categorycode S --cardnumber SEE_THIS_BREAKS
> 
> A new user is added, but the userid isn't admin. In my test case it was 4.
> Ran it 2 more times: 5 and 6. This case needs to be reported and/or
> prevented. If the userid exists, perhaps a nice warning and either die, or
> spit out the new userid.
> 
> Otherwise, it works great in "normal" circumstances.

--userid you mean?
Comment 4 Marcel de Rooy 2018-04-20 07:44:14 UTC
Created attachment 74597 [details] [review]
Bug 20580: Make create_superlibrarian.pl accept parameters

So far this script does not accept parameters and create a koha/koha
superlibrarian
This patch makes it accept parameters to create a customized
superlibrarian patrons.

Test plan:
Use the script with valid and invalid paramters and confirm that it
works as expected.

Note: A cryptic "Invalid parameter passed" error is raised when the
categorycode is not valid. Better error handling must be provided but
Koha::Exceptions seems to be enhancement (see related bug reports).

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 5 Marcel de Rooy 2018-04-20 07:48:26 UTC
Combined SO+QA
I agree that error checking could be improved ;)
But what we have now is better than koha/koha/42.

Still a bit ugly:
DBD::mysql::st execute failed: Duplicate entry '4' for key 'cardnumber' 
DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails
Use of uninitialized value in sprintf at /usr/share/koha/devclone/Koha/Exceptions/Exception.pm line 19.
Invalid parameter passed, branchcode= does not exist

Also note that it is possible to add superlibrarians that are not staff members. This is also possible via the interface. So no blocker. But maybe we should not allow staff permissions for non-staff categories on a new report??
Comment 6 Jonathan Druart 2018-04-20 15:49:51 UTC
Pushed to master for 18.05, thanks to everybody involved!