Bug 20580 - create_superlibrarian.pl should accept parameters
Summary: create_superlibrarian.pl should accept parameters
Status: Pushed to Master
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Marcel de Rooy
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 20489
  Show dependency treegraph
 
Reported: 2018-04-13 13:38 UTC by Jonathan Druart
Modified: 2018-05-03 16:42 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 20580: Make create_superlibrarian.pl accept parameters (4.16 KB, patch)
2018-04-16 15:34 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 20580: Make create_superlibrarian.pl accept parameters (4.24 KB, patch)
2018-04-20 07:44 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 M. 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!