In situations in which you are not familiar with all the Koha settings,
and table structure, the fact this script just fails telling there's a
broken FK is just not practical.
We should capture those exceptions and display a useful message instead.
This script does that. It adds some validations and some exception
handling too. It prints a nice message about the bad value the user
passed, and the valid values too!
To test:
1. Run this on a fresh KTD:
$ ktd --shell
k$ perl misc/devel/create_superlibrarian.pl \
--userid tcohen \
--password tomasito \
--cardnumber 123456789 \
--categorycode POT \
--branchcode ATO
=> FAIL: It explodes with a MySQL exception message!
2. Apply this patch
3. Repeat 1
=> SUCCESS: It tells you which value is wrong and what values you can
pick to make the command work
4. Pick a valid value, and repeat
=> SUCCESS: Now the other value is wrong, a nice message is displayed!
5. Fix with a valid value and repeat
=> SUCCESS: Patron created!
6. Sign off :-D
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
When misc/devel/install_plugins.pl does not find any plugins, it prints
the list of pluginsdir, but with a literal \n separating the dirs, and
no newline at the end.
To test:
- Edit koha-conf.xml and add a second entry for <pluginsdir>, so there
are two entries. The second one could just be a copy of the original.
- Run "perl misc/devel/install_plugins.pl"
- Note the output looks something like this:
No plugins found
pluginsdir contains:
/var/lib/koha/kohadev/plugins\n/var/lib/koha/kohadev/pluginsroot@kohadevbox:koha(master)$
- Apply the patch and run the script again. Output should be:
No plugins found
pluginsdir contains:
/var/lib/koha/kohadev/plugins
/var/lib/koha/kohadev/plugins
root@kohadevbox:koha(master)$
- Sign off
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Three routines in Plugins got the verbose parameter on 35507.
We can refine this a bit further.
The idea here is report when you are installing plugins but not
report when just calling plugins (flooding logs).
[1] GetPlugins: Most callers do not expect (or check) results for
failing plugins. This patch makes GetPlugins only return
errors when passing the *errors* flag (in 2 cases).
[a] The misc/devel script prints warnings now using verbose,
so does not need the errors flag anymore.
[b] plugins/plugins-home is the only case left. Tiny adjustment
to keep current behavior. Fixed colspan in template.
Does not need verbose in favor of 'errors' (passed to
template).
[c] For most calls we do not want verbose. New default is 0.
[2] InstallPlugins
[a] Disabled verbose in plugin-upload. Not really needed.
Added a FIXME; we need to improve individual install.
[b] misc/devel: No warnings anymore when calling InstallPlugins
after GetPlugins.
[3] get_enabled_plugins
[a] Plugins->call does not need verbose.
[b] Plugins->feature_enabled does not need it too.
Test plan:
[1] See previous plan. With TestMR data but without patch, run
misc script and go to plugins-home. Do you see load errors on
commandline or form?
[2] Run plugins/plugins-upload (uploading just some file is good
enough); verify that you do not see TestMR lines in logfile.
[3] Run t/db_dependent/Koha/Plugins/Plugins.t for the additional
test on verbose and errors flag.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
On bug 17591 we discovered that there was something weird going on with
the way we export and use subroutines/modules.
This patch tries to standardize our EXPORT to use EXPORT_OK only.
That way we will need to explicitely define the subroutine we want to
use from a module.
This patch is a squashed version of:
Bug 17600: After export.pl
Bug 17600: After perlimport
Bug 17600: Manual changes
Bug 17600: Other manual changes after second perlimports run
Bug 17600: Fix tests
And a lot of other manual changes.
export.pl is a dirty script that can be found on bug 17600.
"perlimport" is:
git clone https://github.com/oalders/App-perlimports.git
cd App-perlimports/
cpanm --installdeps .
export PERL5LIB="$PERL5LIB:/kohadevbox/koha/App-perlimports/lib"
find . \( -name "*.pl" -o -name "*.pm" \) -exec perl App-perlimports/script/perlimports --inplace-edit --no-preserve-unused --filename {} \;
The ideas of this patch are to:
* use EXPORT_OK instead of EXPORT
* perltidy the EXPORT_OK list
* remove '&' before the subroutine names
* remove some uneeded use statements
* explicitely import the subroutines we need within the controllers or
modules
Note that the private subroutines (starting with _) should not be
exported (and not used from outside of the module except from tests).
EXPORT vs EXPORT_OK (from
https://www.thegeekstuff.com/2010/06/perl-exporter-examples/)
"""
Export allows to export the functions and variables of modules to user’s namespace using the standard import method. This way, we don’t need to create the objects for the modules to access it’s members.
@EXPORT and @EXPORT_OK are the two main variables used during export operation.
@EXPORT contains list of symbols (subroutines and variables) of the module to be exported into the caller namespace.
@EXPORT_OK does export of symbols on demand basis.
"""
If this patch caused a conflict with a patch you wrote prior to its
push:
* Make sure you are not reintroducing a "use" statement that has been
removed
* "$subroutine" is not exported by the C4::$MODULE module
means that you need to add the subroutine to the @EXPORT_OK list
* Bareword "$subroutine" not allowed while "strict subs"
means that you didn't imported the subroutine from the module:
- use $MODULE qw( $subroutine list );
You can also use the fully qualified namespace: C4::$MODULE::$subroutine
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
To test:
1 - Enable plugins in the koha-conf
2 - Install the kitchen sink plugin
3 - Your staff client should be orange now :-)
4 - edit the plugin module
/var/lib/koha/kohadev/plugins/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm
5 - Add a line to break compilation, like:
this won't compile
6 - Restart all
7 - Your koha is now broken
8 - kshell
9 - perl misc/devel/install_plugins.pl
10 - Restart all
11 - Koha remains broken
12 - Apply patch
13 - kshell
14 - perl misc/devel/install_plugins.pl
15 - Koha now works!
16 - Koha is not orange because the plugin methods are removed
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Also fix code style with perltidy
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
The script is very simple, it just calls GetPreparedLetter with
arguments given on command line and print the resulting letter content
Usage example:
misc/devel/get-prepared-letter.pl --module circulation \
--letter_code ODUE --tables '{"borrowers":1,"branches":"CPL"}' \
--repeat '{"item":[{"biblio":1,"items":1}]}' \
--loops '{"overdues":[1]}'
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Works for the example and other cases.
Correct option is 'letter-code', with dash, not underscore.
An usage message would be nice.
No errors
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
JD amended patch: tidy the new file and rename it matching the other
scripts' names in this directory
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This adds a --force option to the aforementioned script allowing those
in the know to overwrite the schema when changes above the found are
detected.
Signed-off-by: Ere Maijala <ere.maijala@helsinki.fi>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Recent versions of MariaDB changed the output of 'DESCRIBE' for
timestamp columns with defaults from `CURRENT_TIMESTAMP` to
`current_timestamp()`. As such the code inside
DBIx::Class::Schema::Loader which catches such cases and outputs
`\"current_timestamp"` as a sensible cross platform default is missed
and this leads of inconsistent class files and bugs with out default
lookup code in Koha::Objects.
This patch serves as a backport of the code I have submitted upstream
such that out developers can continue to use update_dbix_class_files.pl
to build their schema classes from the database and regardless of their
db server version get a consistently correct output.
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Owen Leonard 2018-03-16 10:47:47 UTC :
<<
I don't think the system preference adds any security. There are already multiple permissions required for working with plugins:
- Configure plugins
- Manage plugins ( install / uninstall )
- Use report plugins
- Use tool plugins
And even with those permissions your server must be configured to allow the use of plugins.
>>
Test plan :
1) Install kitchen sink plugin https://github.com/bywatersolutions/koha-plugin-kitchen-sink
2) Run misc/devel/install_plugins.pl
3) Set config enable_plugins=1
4) Check all parts of the plugin are working
5) Set config enable_plugins=0
6) Check all parts of the plugin are disabled
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
It is annoying to have to specify database connection parameters each
time DBIx::Class files need to be updated.
This patch adds a new option --koha-conf that takes an optional <path>
which defaults to the value of KOHA_CONF environment variable, and use
the database connection parameters found in that file.
--db_* options override values from $KOHA_CONF
Test plan:
1. Run the script with the same parameters as before the patch and see
that it still works.
Example:
misc/devel/update_dbix_class_files.pl --db_name koha_dev \
--db_user koha --db_pass koha
2. Verify that KOHA_CONF is set and execute:
misc/devel/update_dbix_class_files.pl --koha-conf
Verify that Koha/Schema files were updated accordingly
3. Execute:
misc/devel/update_dbix_class_files.pl --koha-conf \
/path/to/another/koha-conf.xml
Verify that Koha/Schema files were updated accordingly
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
populate_db.pl from koha-misc4dev must be used instead.
This script existed before the creation of koha-misc4dev, it does no
longer make sense to have it in Koha.
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This patch adds a check of what plugins installed before the script run
and outputs only those plugins that have been installed for the first
time or upgraded during this run.
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This adds an initial skeliton script to enable plugin installation at
the commandline.
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This patch change Koha::Cron to be a more generic Koha::Script class and
update all commanline driven scripts to use it.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Use $patron->set_password instead of update_password. In this case the
'skip_validation' param needs to be set as no password strength checks
are expected.
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
See bug 13618 and bug 21526.
We need a script to add missing filters, or replace wrong ones.
Test plan:
- Add unescaped variables to .tt files
- prove xt/find-missing-filters.t
will warn about them
- perl misc/devel/add_missing_filters.pl
will add the missing/wrong filters
- prove xt/find-missing-filters.t
will now be happy
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
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>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
To test:
- Have a clean install, no DB
- Run populate_db.pl:
$ sudo koha-shell kohadev
k$ cd kohaclone
k$ misc/devel/populate_db.pl
- Go to
http://localhost:8081/cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl
=> FAIL: No mappings
- Delete the DB and create an empty one:
$ mysql -uroot
> DROP DATABASE koha_kohadev; CREATE DATABASE koha_kohadev;
> GRANT ALL PRIVILEGES ON koha_kohadev.* TO
'koha_kohadev'@'localhost';
- Run populate_db.pl:
$ sudo koha-shell kohadev
k$ cd kohaclone
k$ misc/devel/populate_db.pl
- Go to
http://localhost:8081/cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl
=> SUCCESS: There are mappings!
- Sign off :-D
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Adding POD and --userid and --password options
1/ To test, use the same routine as before, with no options.
2/ You should have a user with koha/koha as userid and passwords
3/ Delete that user
4/ Run the script with --userid <userid> --password <password>
5/ You should have a user in koha with userid/password set
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This is for developers: it's quite long (many clics) to create a new
superlibrarian user.
This new script creates a new user with superlibrarian permissions with
the easy to remember credential koha/koha
Test plan:
perl misc/devel/create_superlibrarian.pl
Log in to Koha using koha/koha
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This patch makes the populate_db.pl script upper case what gets passed
with the --marcflavour option switch. This is needed in order for this
to fit ``kohadevbox`` configuration files, and it is harmless for other
uses.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This patch enables the --marcflavour option switch so the user
can specify the desired marc flavour. The code for handling it
was already in place, just not used.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Executing the installer process and inserting all the sample data take a
lot of clics and time.
The idea of this script is to provide a quick way to insert all the
sample data easily to get a working Koha install asap.
Test plan:
- Set your database config to a non-existent DB
- Execute perl misc/devel/populate_db.pl
You will get an error
- Create an empty DB
- Execute perl misc/devel/populate_db.pl
It will insert all the MARC21 sample data
- Execute perl misc/devel/populate_db.pl
You will get an error because the DB is not empty (systempreferences and
borrowers tables)
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
The swagger specification file is currently being minified adding
manual steps to release management and restful api route development.
The minification is not required; The deferenced version of the
specification is now internally validated at runtime and relavant errors
output and the dereferenced schema has been made publically available at
/api/v1/spec, so it can be copy&pasted into validation tools
Test Plan
1) Apply patch
2) Ensure api routes still function (applying the /cities patch might be
helpful)
3) Ensure /api/v1/spec page exists (it should be the de-referenced
swagger.json file)
Signed-off-by: Claire Gravely <claire_gravely@hotmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
This patch introduces the misc/devel/minifySwagger.pl script that
loads the Swagger files, follows references and produces a compact
("minified") version of the swagger file which is suitable for
distribution.
The wiki page should be updated with instructions on how to regenerate
it so the Release Manager does it on each spec upgrade.
Signed-off-by: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi>
My name is Olli-Antti Kivilahti and I approve this commit.
We have been using the Swagger2.0-driven REST API on Mojolicious for 1 year now
in production and I am certain we have a pretty good idea on how to work with
the limitations of Swagger2.0
Signed-off-by: Johanna Raisa <johanna.raisa@gmail.com>
My name is Johanna Räisä and I approve this commit.
We have been using Swagger2.0-driven REST API in production successfully.
Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Most of them were found and fixed using codespell.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
koha-qa should be good :
OK misc/devel/coverage.pl
OK critic
OK forbidden patterns
OK pod
OK valid
OK C4/Installer/PerlDependencies.pm
OK critic
OK forbidden patterns
OK pod
OK valid
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
No koha-qa errors.
Test plan not explicitly stated,
script run and generates a lot of data :)
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Fixed a small conflict on PerlDependencies.pm
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
It's a script making a cover on all modules to see
which ones are not tested yet. It uses Devel::Cover
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Changes make sense, tested by confirming that a patron
modification request for B_<columns> no longer results in
an error message.
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This patch changes update_dbix_class_files.pl so that the connection
parameters to the reference database must be passed explicitly via
command-line switches, rather than grabbing them from the current Koha
context.
The purpose of this is to intentionally put up a roadblock to reduce
the chance that a developer (or release manager) accidentally updates
the schema files to include local testing cruft such as temporary
tables.
Usage is now as follows:
[1] Create an empty database
[2] Load the schema creation script into it, e.g.,
mysql -u dbic -pdbic dbic < installer/data/mysql/kohastructure.sql
[3] Run the schema updater:
./misc/devel/update_dbix_class_files.pl --db_user=dbic --db_name=dbic --db_passwd=dbic
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
updateDatabase.pl is a bit too close to updatedatabase.pl in installer
and may cause some confusion. I would suggest update_dbix_class_files.pl
as a unambiguous and descriptive name for this file.
Signed-off-by: wajasu <matted-34813@mypacks.net>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
* Added base class files for all tables in koha using
DBIx::Class::Schema::Loader.
* Added a (very basic) test file for C4::Context
* Also added dependencies in required files.
To Test:
[1] Install patch
[2] Make sure you can still connect to Koha
[3] You may optionally run this test script:
use Koha::Database;
use Data::Dumper;
my $db = Koha::Database->new();
my $schema = $db->schema();
print Dumper($schema->resultset("Borrower"));
If you run this file you should get a DBIx dump of the borrowers table.
Signed-off-by: wajasu <matted-34813@mypacks.net>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>