Commit Graph

88 Commits

Author SHA1 Message Date
David Cook 90f173ac6a
Bug 38365: Add context to Koha::Devel::Files in add_csp_nonces.pl
The add_csp_nonces.pl file should use the exceptions in
Koha::Devel::Files.

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:41 +01:00
David Cook e011f2f6e1
Bug 38365: Make tidy.pl compatible with script elements with attributes
tidy.pl will still tidy whitespace around script elements that have
attributes like "nonce"

Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:38 +01:00
Jonathan Druart bba61e6bc9
Bug 38365: Use Koha::Devel::Files->ls_tt_files in add_csp_nonces.pl
Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:35 +01:00
David Cook f80451023e
Bug 38365: Add <style to add_csp_nonces.pl to add nonce to style elements
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>
Signed-off-by: David Cook <dcook@prosentient.com.au>

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:16 +01:00
Martin Renvoize e8d11cc102
Bug 38365: Add script to insert CSP nonces into templates
Add misc/devel/add_csp_nonces.pl which automatically adds CSP nonce
attributes to inline <script> tags in Koha templates.

The script:
- Finds all .tt and .inc files in koha-tmpl/
- Adds nonce="[% Koha.CSPNonce | $raw %]" to inline scripts
- Skips external scripts (those with src= attribute)
- Skips scripts that already have nonce= attribute
- Skips third-party library files in lib/ and vendor/

Usage:
  perl misc/devel/add_csp_nonces.pl          # Dry run
  perl misc/devel/add_csp_nonces.pl --apply  # Apply changes

This script enables easy backporting of CSP nonce support to older
Koha versions by running it against their template directories.

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>
Signed-off-by: David Cook <dcook@prosentient.com.au>

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2026-03-16 11:57:14 +01:00
Aleisha Amohia c72fc81b76
Bug 38549: Provide surname for create_superlibrarian.pl
Interestingly this script already had a $surname variable, just never accepted a parameter for it.

This enhancement enables the user to supply a surname parameter when creating a superlibrarian user via the commandline create_superlibrarian.pl script. Koha patrons MUST have a name, so if no surname is provided, the userid will be used for the surname instead.

To test:

1. Apply the patch and restart services
2. Attempt to create a superlibrarian with no surname provided.
  In KTD: misc/devel/create_superlibrarian.pl --userid test --cardnumber test --password XXXX --branchcode CPL --categorycode S
3. Search for your patron in Koha. Confirm the surname was automatically set to the userid 'test'
4. Attempt to create a superlibrarian, this time provide a surname that is different from the userid so easy to tell apart.
  In KTD: misc/devel/create_superlibrarian.pl --userid test1 --cardnumber test1 --password XXXX --branchcode CPL --categorycode S --surname testsurname
5. Search for your patron in Koha. Confirm the surname was set correctly using the given surname.

Sponsored-by: Catalyst IT
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-02-27 11:38:43 -07:00
Tomas Cohen Arazi 1873d97c07
Bug 40163: Fix several http addresses in the code docs
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-09-23 16:21:29 -06:00
Pedro Amorim 77b1fe53ef
Bug 34978: (QA follow-up) Fix rebase issues
- Rebased tests patch (62->51)
- tidy
- spelling ( paramater -> parameter )

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Hammat Wele <hammat.wele@inlibro.com>
Signed-off-by: Amaury GAU <amaurygau@gmail.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-08-14 16:05:56 -06:00
Emily-Rose Francoeur dd60490292
Bug 34978: Add --include and --exclude options to install_plugins.pl
I have added the options --include and --exclude to the install_plugins.pl script. When running the script, you can now specify which plugins you want to install (--include) and which ones you do not want to install (--exclude).

--include installs only the plugins from the specified classes.
--exclude installs all plugins except those from the specified classes.
It's possible to specify the package to install a specific plugin.
--include and --exclude cannot be used simultaneously.

Usage example:
./misc/devel/install_plugins --include <package::pluginClass> --include <anotherPluginClass>"

TEST PLAN
1) Apply the patch
2) Add at least three plugins to the plugin directory ([Koha]/plugins/Koha/Plugin/)
3) Empty the "plugin_data" and "plugin_methods" tables (SQL command: "delete from plugin_data; delete from plugin_methods;")
4) In a terminal, execute this command "./misc/devel/install_plugins.pl --include <package::pluginClass> --include <anotherPluginClass>" (Replace <package::pluginClass> and <anotherPluginClass> with the class and package of your plugins)
5) In your Koha intranet, go to "Koha administration > Manage plugins"
6) Verify that only the specified plugins are installed
7) Repeat step 3
8) In a terminal, execute this command from your Koha project"./misc/devel/install_plugins.pl --exclude <package::pluginClass> --exclude <anotherPluginClass>"
9) Verify that all plugins except the specified ones are installed
10) Run the tests from the Plugins.t file ([Koha]/t/db_dependent/Koha/Plugins/Plugins.t)
11) Ensure that all tests are successful

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Hammat Wele <hammat.wele@inlibro.com>
Signed-off-by: Amaury GAU <amaurygau@gmail.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-08-14 16:05:56 -06:00
Jonathan Druart e7e42c5e88
Bug 39876: Add context for tidy
With this patch we adjust what's needed to make misc/devel/tidy.pl run
identically as before

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-08 15:41:59 -06:00
Jonathan Druart 1d4071298c
Bug 39876: Move `git ls-files` to Koha::Devel::Files
This patch introduces a new Koha::Devel namespace. It clearly shows
that its purpose is for development and will not contain any business
logic.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-08 15:41:58 -06:00
Jonathan Druart 1d844a7d2f
Bug 39325: Automatic fix
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-28 18:51:22 +02:00
Emily Lamancusa 8ae546b31b
Bug 39353: (QA follow-up) Clarify error message
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-19 17:34:54 +01:00
Jonathan Druart 488d0042e6
Bug 39353: Prevent tidy.pl to empty template files
In ktd context:
if host's node_modules ktd has been generated prior to bug 38644, the template-toolkit's
prettier plugin is not there and prettier will empty the file.

It seems to be a prettier bug, and the following behaviour is confusing:

From the host:
% yarn run prettier --write koha-tmpl/intranet-tmpl/prog/en/modules/test.tt
yarn run v1.22.22
$ prettier koha-tmpl/intranet-tmpl/prog/en/modules/test.tt
[error] Cannot find module '@koha-community/prettier-plugin-template-toolkit'
[error] Require stack:
[error] - /home/jonathan/workspace/koha/node_modules/prettier/index.js
[error] - /home/jonathan/workspace/koha/node_modules/prettier/cli.js
[error] - /home/jonathan/workspace/koha/node_modules/prettier/bin-prettier.js
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

=> The file is not modified

Within ktd:
$ yarn run prettier --write koha-tmpl/intranet-tmpl/prog/en/modules/test.tt
yarn run v1.22.22
$ prettier --write koha-tmpl/intranet-tmpl/prog/en/modules/test.tt
koha-tmpl/intranet-tmpl/prog/en/modules/test.tt 6ms
Done in 0.39s.

=> No error, and the file is emptied!

It seems that the plugin is found by prettier but not used (?)

Test plan:
1. Follow this from step 1 to 14
   https://gitlab.com/koha-community/koha-testing-docker/-/issues/483
2. Apply patch
3. misc/devel/tidy.pl --no-write koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
   It should print the new error message
4. Make a change to a .tt file, commit
5. There will be a message about and issue with prettier. But it will
   still commit. It's expect.
6. Inspect and see that the commit has the changes

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-19 17:34:54 +01:00
Jonathan Druart 73edc6cf38
Bug 39115: get_tt_files should exclude dirs from tt, not js
Silly copy/paste error

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-03-13 10:29:17 +01:00
Tomas Cohen Arazi 63cba14abd
Bug 39149: Make tidy.pl deal with .PL files
This patch adds handling for files with the `.PL` extension to the
`tidy.pl` helper script.

It will now consider them Perl files and tidy them as appropriate.

I opted for explicitly listing `PL` instead of making the existing check
case-insensitive because the only files I found with changed case (i.e.
Perl scripts that don't have `.pl`) are:

$ find . -type f -iname "*.pl" ! -name "*.pl"
./fix-perl-path.PL
./build-resources.PL
./rewrite-config.PL
./Makefile.PL

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-18 15:35:52 +01:00
Tomas Cohen Arazi 57f271d6b2
Bug 39106: Use LWP::UserAgent and add error checking
This patch replaces the (newly introduced use of) REST::Client library
with (the already existing in the dependencies) LWP::UserAgent.

Bonus 1: validation on the response status is added to print a proper
error message and die if bugzilla is not available

Bonus 2: License added to the file

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-17 13:10:24 +01:00
Jonathan Druart d58e670ffe
Bug 39106: The auto-rebase script - Add --bugzilla
Julian wrote a script a while ago to retrieve patches from bugzilla
and checkout the good commit to make sure the patches will apply cleanly.

This change reuses the same logic for the auto-rebase script.

Test plan:
0.
 a. You will need to install REST::Client using cpanm:
  `cpanm REST::Client`
 b. You need the --confirm flag from git-bz, see https://gitlab.com/koha-community/git-bz/-/issues/14
1. Pick a bug number with patches that does not apply on current main
2. Use the auto_rebase script with the --bugzilla option
3. Enjoy

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-17 13:10:23 +01:00
Jonathan Druart 2a3fe18734
Bug 39115: Finally use ':(exclude)' and grep
This was not working:
% git ls-files Koha/Schema.pm --exclude='Koha/Schema/Result' --exclude='Koha/Schema.pm'
Koha/Schema.pm

The efficiency of the script is getting worse and it will need to be
rewritten.
The xt/tt_tidy.t will take longer.

But at least it should work correctly now

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-17 13:10:22 +01:00
Jonathan Druart 44c7c99132
Bug 39115: Restore ability to tidy files not in git index (yet)
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-17 13:10:21 +01:00
Jonathan Druart 9d1bdfd07f
Bug 39115: Replace (:exclude) with --exclude
I don't really explain this one, but this is something wrong with
(:exclude)

% git ls-files koha-tmpl/intranet-tmpl/js/i18n.js --exclude='koha-tmpl/intranet-tmpl/lib' --exclude='koha-tmpl/intranet-tmpl/js/Gettext.js' --exclude='koha-tmpl/opac-tmpl/lib'
koha-tmpl/intranet-tmpl/js/i18n.js
=> Return the file has expected

% git ls-files koha-tmpl/intranet-tmpl/js/i18n.js ':(exclude)koha-tmpl/intranet-tmpl/lib' ':(exclude)koha-tmpl/intranet-tmpl/js/Gettext.js' ':(exclude)koha-tmpl/opac-tmpl/lib'
=> Does not return anything!

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-17 13:10:21 +01:00
Jonathan Druart 8ba8b9b1ce
Bug 39115: Do not tidy files that must not be touched
It should prevent to tidy files that must be kept unchanged.

It was initially a feature (the script does what you ask it to do),
but it's a mess maintain the list of files we want to keep tidy.

Test plan:
Koha/Schema.pm is one of the file we don't want to modify/tidy
So let's play with this one, feel free to pick others (see the
exception list per filetype in the script)

 % perl misc/devel/tidy.pl --perl
will not touch Koha/Schema.pm

 % perl misc/devel/tidy.pl mainpage.pl Koha/Schema.pm
will not touch Koha/Schema.pm but mainpage.pl will

 % perl misc/devel/tidy.pl --no-write Koha/Schema.pm
The --no-write option is called by the QA script to compare the output
and see if files are tidy. We want to return something in this case. So
the file will be printed to STDOUT untouched

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-17 13:10:19 +01:00
Jonathan Druart 5dcfb91db3
Bug 39114: The auto-rebase script - Fix files removal
Wrong handling of the return of the try-catch, $git->rm has an output
("rm /file/path").

This patch retrieves the status from the `git diff-tree` output

Test plan:
git checkout HEAD~100 (so you are before 38664)
git rm mainpage.pl
edit C4/Auth.pm and make some changes
git commit -a --no-verify -m"Bug 12345: test"
then rebase your branch
Retrieve the auto_rebase.pl version from this patch and run it
perl auto_rebase.pl

The resulted commit should not contain mainpage.pl

WNC amended patch, tidied, ironically

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-13 17:11:10 +01:00
Jonathan Druart 2ebf61c174
Bug 39126: tidy - Show error if stderr_buf is empty
If yarn is not installed:
Tidying file 1/1 (koha-tmpl/intranet-tmpl/prog/fr-FR/modules/intranet-main.tt)
Warning: something's wrong at misc/devel/tidy.pl line 79.

There is the error hidden in $error_message
open3: exec of yarn --silent run prettier --write koha-tmpl/intranet-tmpl/prog/fr-FR/modules/intranet-main.tt failed: No such file or directory

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-13 15:30:56 +01:00
Jonathan Druart a76a1f0073
Bug 38664: The auto-rebase script - Create parent directory if missing
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-12 12:12:16 +01:00
Jonathan Druart 6daf09496a
Bug 38664: Add a xt test for TT files 2025-02-11 23:39:26 +01:00
Jonathan Druart aea905f704
Bug 38664: Fix the auto_rebase script
I had the tidy.pl script with correct +x permission during my testing
session. Now we retrieve it from main, write its content into a
temporary file. It does not have the +x bit.
2025-02-11 22:31:23 +01:00
Jonathan Druart fa10e13691
Bug 38664: Manual revert
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:26 +01:00
Jonathan Druart aa24f1e6d1
Bug 38664: Treat .vue files like other JS files
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:25 +01:00
Koha Development Team d659526b5a
Bug 38664: Tidy the whole codebase
This commit is generated using:
  % perl misc/devel/tidy.pl
*within* ktd, to get the same version of perltidy than what will be used
by our CI (currently v20230309).

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:24 +01:00
Jonathan Druart a3c5620cc6
Bug 38664: The tidy script: remove blank line after SWITCH
The prettier plugin does not deal correctly with SWITCH
https://gitlab.com/koha-community/prettier-plugin-template-toolkit/-/issues/2

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:22 +01:00
Jonathan Druart 616102740a
Bug 38664: The tidy script - Implement --no-write and --silent
To ease comparisons, from the QA script

Bug 38664: Fix perltidyrc option

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:22 +01:00
Jonathan Druart 287cb328bc
Bug 38664: Move prettier options to .prettierrc.js
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:20 +01:00
Jonathan Druart c531081d86
Bug 38664: The auto-rebase script - use misc/devel/tidy.pl from the target branch
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:20 +01:00
Jonathan Druart ba83aa61b4
Bug 38664: The auto-rebase script - Remove the dependency IPC::System::Simple
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:16 +01:00
Jonathan Druart 675ff64ef7
Bug 38664: The tidy script - Remove the dependency IPC::System::Simple
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:15 +01:00
Jonathan Druart ba1aafe9e5
Bug 38664: The tidy script - Fix extra blank lines and spaces around script tags
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:14 +01:00
Jonathan Druart 955521be23
Bug 38664: The tidy script - Add exceptions
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:14 +01:00
Jonathan Druart 745da164ad
Bug 38664: The tidy script - fix race condition - replace edit_file
It seems that File::Slurp::edit_file is not thread safe?
Not sure what's happening here but I end up with corrupted file, or
getting the same error "write_file: No such file or directory"

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:13 +01:00
Jonathan Druart 4a7a8fbef1
Bug 38664: The tidy script - fix race condition
There was a race condition, edit_file trying to open it while it was not
fully written by prettier (?) This is a dirty fix but it seems to do the
trick.

The error was:
edit_file 'koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc' - write_file: No such file or directory at misc/devel/tidy.pl line 149.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:13 +01:00
Jonathan Druart 0cdaf9935f
Bug 38664: The tidy script - tidy tt twice
For an unknown reason the script is not idempotent (!)
Decided to run it twice for now, and have a look at this problem later.
It might be related to the length of the line

Version 0

<div>
    <div class="page-section clearfix">
        <div class="listgroup">
            <h4>
                <span>Statuses</span>
                [% IF foo %]
                    [% IF ( ITEM_DAT.withdrawn ) %]<span>Withdrawn</span>[% END %]
                    [% IF ITEM_DAT.bookable == 1 %] Yes [% ELSIF ITEM_DAT.bookable == 0 %] No [% ELSE %] Follow item type [% END %]

                    [% IF ITEM_DAT.bookable == 1 %] [% t('Yes') %] [% ELSIF ITEM_DAT.bookable == 0 %] [% t('No') %] [% ELSE %] [% t('Follow item type') %] [% END %]
                [% END %]
            </h4>
        </div>
    </div>
</div>

Version 1
<div>
    <div class="page-section clearfix">
        <div class="listgroup">
            <h4>
                <span>Statuses</span>
                [% IF foo %]
                    [% IF ( ITEM_DAT.withdrawn ) %]<span
                        >Withdrawn</span
                    >[% END %]
                    [% IF ITEM_DAT.bookable == 1 %]Yes[% ELSIF ITEM_DAT.bookable == 0 %]No[% ELSE %]Follow
                    item type[% END %]

                    [% IF ITEM_DAT.bookable == 1 %][% t('Yes') %][% ELSIF ITEM_DAT.bookable == 0 %][% t('No') %][% ELSE %][% t('Follow item type') %][% END %]
                [% END %]
            </h4>
        </div>
    </div>
</div>

Version 2
div>
    <div class="page-section clearfix">
        <div class="listgroup">
            <h4>
                <span>Statuses</span>
                [% IF foo %]
                    [% IF ( ITEM_DAT.withdrawn ) %]
                        <span>Withdrawn</span>
                    [% END %]
                    [% IF ITEM_DAT.bookable == 1 %]
                        Yes
                    [% ELSIF ITEM_DAT.bookable == 0 %]
                        No
                    [% ELSE %]
                        Follow item type
                    [% END %]

                    [% IF ITEM_DAT.bookable == 1 %][% t('Yes') %][% ELSIF ITEM_DAT.bookable == 0 %][% t('No') %][% ELSE %][% t('Follow item type') %][% END %]
                [% END %]
            </h4>
        </div>
    </div>
</div>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:12 +01:00
Jonathan Druart 2c6f9d31b6
Bug 38664: The tidy script
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:12 +01:00
Jonathan Druart a9c0a70f67
Bug 38664: The auto-rebase script
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:11 +01:00
Kyle M Hall 576621a6df
Bug 37448: Add script to allow developers to quickly generate large amounts of data for development and testing
Test Plan:
1) Apply this patch
2) Run: misc/devel/create_test_data.pl -n 99 -s Borrower -d surname=Hall  -d zipcode=111111
3) Search patrons' for the name "Hall"
4) Note there are 99 Hall's in your results!

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>

Bug 37448: Make use of build_sample_biblio and build_sample_item

The script is brilliant, but for biblios and items we should make use of build_sample_biblio and build_sample_item or this data does not get indexed + linked tables rows get missed

To test, before this patch, run:
1) misc/devel/create_test_data.pl -n 5 -s Biblio -d title=Test
  Notice the 'Test' biblio is created on the database, but doesnt show on searches, and accessing it directly through URL throws a 500 error (because metadata does not exist for the biblio)
2) Apply this patch. Repeat the step above. Notice it now shows on searches and visiting the biblio directly shows no errors

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Bug 37448: (QA follow-up) Tidy script

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-10 19:19:26 +01:00
Tomas Cohen Arazi df1f5da673
Bug 36309: Make create_superlibrarian.pl output more useful
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>
2024-04-22 08:57:35 +02:00
Magnus Enger 4848def5e2
Bug 36517: Fix output from install_plugins.pl
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>
2024-04-12 11:26:01 +02:00
Fridolin Somers 1ff71cf200
Bug 36323: Move koha_perl_deps.pl to misc/devel
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>
2024-04-03 17:05:51 +02:00
Marcel de Rooy d8e04545b8
Bug 35536: Refine verbose handling in some Koha::Plugins calls
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>
2024-03-22 12:26:40 +01:00
Jonathan Druart 9d6d641d1f Bug 17600: Standardize our EXPORT_OK
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>
2021-07-16 08:58:47 +02:00
Nick Clemens 0eae966d25 Bug 25549: Remove plugin methods for broken plugins
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>
2020-10-22 10:04:30 +02:00