Commit Graph

3721 Commits

Author SHA1 Message Date
Janusz Kaczmarek e7b0211750
Bug 33238: Fix bad suggestions query (Bug 29886 follow-up)
With IndependentBranches Koha explodes with Error 500 when a non
superlibrarian tries to add to basket from suggestions.  In errorlog you
would find "DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception:
DBD::mysql::st execute failed: Column 'branchcode' in where clause is
ambiguous".

Test plan:
==========
1. Have a Koha instance with IndependentBranches, some accepted
   suggestions, and a vendor defined.
2. Be a non superlibrarian librarian with permissions to
   manage acquisitions.
3. Create a new basket and try to add an item to the basket
   "From a suggestion".
4. Koha would generate error 500.
5. Apply the patch.
6. Try to add an item to the basket "From a suggestion".
7. You should succeed.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 68b2f29d48)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
(cherry picked from commit d4fb687030)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit f849dd313c)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2023-05-23 20:43:31 +02:00
Pedro Amorim 0b18e0b07e Bug 28641: ILLHiddenRequestStatuses does not consider custom statuses
This patch adds the status_alias column to the ILLHiddenRequestStatuses sys pref check.
Because requests will have status_alias NULL by default, we also check for that.

Test plan:
Create multiple ILL requests of different backends and place them in different status (NEW, COMP, REQ, etc)
Create multiple ILLSTATUS entries
Add and remove a mix of both status and status_alias codes in ILLHiddenRequestStatuses and refresh the ILL requests page to confirm the result is according to expectation.

Sponsored-by: PTFS Europe

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit aaa5bcd16b)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
(cherry picked from commit feea30d42b)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 3735277be4)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2023-05-03 21:07:24 +02:00
Tomas Cohen Arazi 92ad549936 Bug 33341: Address some perlcritic errors in 5.36
Some old-style code is making our tests fail when run in Debian Testing.

This patch addresses this.

To test:
1. Launch bookworm KTD:
   $ KOHA_IMAGE=master-bookworm ktd up -d
2. Run:
   $ ktd --shell
  k$ prove t/00-testcritic.t
=> FAIL: It fails!
3. Apply the patch
4. Repeat 2
=> SUCCESS: Tests now pass!
5. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 10d12f999f)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
(cherry picked from commit c1c5420afa)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 548a3325ba)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2023-05-03 21:03:35 +02:00
Nick Clemens 4a2ef7f1b3 Bug 33309: Index items after renewal transaction completes
This patch ensures a record is indexed only after the renewal transaction
has completed successfully. Otherwise the job cannot be found by the background process
worker, becaue it was not yet in the DB

To test:
1 - Make sure you are using ES, and the es indexer is running
2 - tail -f /var/log/koha/kohadev/*.log
3 - Issue an item to a patron and renew it
4 - Note error in es-indexer-output.log like:
    [2023/03/21 12:22:36] [WARN] No job found for id=157 main:: /kohadevbox/koha/misc/workers/es_indexer_daemon.pl (129)
5 - Apply patch
6 - Renew again
7  There should be no error
8 - Search for the record and confirm items info displays correctly
9 - View the background jobs in admin, confirm the most recent job has completed

Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit a63b0d0030)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
(cherry picked from commit ff03813f9f)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 0081194b40)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2023-05-03 20:37:34 +02:00
Nick Clemens b5a3c68737
Bug 33044: Return job id if there is no connection to rabbit
This patch simply ensures we return the job id even if we couldn't send
the job to rabbit.

To test:
1 - In KTD: sudo service rabbitmq-server stop
2 - sudo koha-worker --stop kohadev; sudo koha-worker --queue long_tasks --stop kohadev
3 - In staff client enqueue a batch item modification - note the link to view the enqueued job has no id in the url and takes you to the main background jobs viewer
4 - Run t/db_dependent/Koha/BackgroundJob.t and notice that it fails.
5 - Apply patch
6 - Restart all
7 - Enqueue a new batch item modification
8 - Confirm the link works and has the correct id
9 - Run t/db_dependent/Koha/BackgroundJob.t; it should pass now.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit b93b6f3dde)
Signed-off-by: Jacob O'Mara <jacob.omara@ptfs-europe.com>
(cherry picked from commit 99454c3885)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit ff7b0a0cdd)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2023-03-29 14:53:57 +02:00
Marcel de Rooy f85440e677 Bug 32472: [21.11] Force scalar context on acqorder->items
This resolves a crash like
    The method Koha::Item->count is not covered by tests!
on the template construction
    [% IF ( order.items.count ) %]
in koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt.

Test plan (21.11):
Receive an order line under this condition: quantityreceived>0 with
items attached to the order line.
Note: Should be possible, comes from production logs.

Look for list context on ->items called from acqorder.
The result of git grep "\->items" is too wide but we could theoretically
miss an occurence with git grep "order.*\->items". With order.* we do
catch $new_order_object->items..

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi>
2023-03-06 14:43:49 +00:00
Marcel de Rooy 0336b27bf6 Bug 32472: Fix wrong POD for bookseller->subscriptions
You should not call this in list context anymore after
bug 29844.

Test plan:
Check pod of Bookseller.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi>
2023-03-06 14:43:49 +00:00
David Cook f8a4bf4528 Bug 32539: Add exception handling to plugin hooks in template plugin
This change wraps Koha plugin hook calls with exception handling
within the template plugin for Koha plugins.

Test plan:
0) Apply patch
1) Install a plugin that provides "opac_head", "opac_js",
"intranet_head", and "intranet_js" with Perl errors in them
2) Load an OPAC page
3) Note that the OPAC page loads correctly
4) Load a staff interace page
5) Note that the staff interface page loads correctly

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 23a0021122)
Signed-off-by: Jacob O'Mara <jacob.omara@ptfs-europe.com>
(cherry picked from commit 0623ba78e5)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 19772ed318)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2023-02-17 14:10:14 +01:00
Kyle Hall 3b053b0d79 Bug 28672: (QA follow-up) Method calls cannot be interpolated directly
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 8939c58a86)
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
(cherry picked from commit 6f2aeda4c3)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 5ed8ae3329)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2023-02-17 14:04:49 +01:00
Martin Renvoize 41dc9ce95e Bug 28672: Pass itemnumber instead of item object
The warn call here was passing the full item object which leads to
HASH() in the logs.. this patch updates it to pass the itemnumber which
is more helpful.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit c89c25d81a)
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
(cherry picked from commit bc23e4a1d8)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit ab792fa6c8)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2023-02-17 14:04:49 +01:00
Nick Clemens fcd9c93caf Bug 31644: Check if subfield defined, not for truth
To test:
1 - Define a new MARC Modification template with actions:
        Copy field 600$a to 942$0
2 - Define a new record like:
    LDR 00334nam a22001217a 4500
    003 ff
    005 20201102111604.0
    008 201102b        xxu||||| |||| 00| 0 eng d
    040 _ _ ‡cvsd
    100 1 _ ‡012345‡aKnuth, Donal Ervin‡d1938
    245 _ _ ‡012345‡aThe aty of computer programming‡cDonald E. Knuth
    600 _ 0 ‡042‡aComputer programming‡9462
3 - Modify this record using the template above
4 - Note that entire  field is copied to 942
5 - Apply patch
6 - Now only subfield 0 is copied

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 2f61afa9c5)
(cherry picked from commit 448f7d1432)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-12-16 15:31:51 +01:00
Kyle M Hall 11dd796287 Bug 31684: Plugin versions starting with a "v" cause unnecessary warnings
Our code assumes that plugin version will be purely numeric ( e.g. 1.2.3 ) but many plugin authors ( including myself ) use the format "v1.2.3".
This causes warnings as we use a numeric comparison on the version numbers.
It could make sense to check for and strip any v's from the beginning of the version.

Test Plan:
1) Apply the first patch to set the test plugin's version to v1.01
2) prove t/db_dependent/Koha/Plugins/Plugins.t
3) Note the warnings and test failures
4) Apply this patch
5) prove t/db_dependent/Koha/Plugins/Plugins.t
6) All tests pass!

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit fd51a238c8)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit a88895d0b8)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-12-16 14:33:33 +01:00
Nick Clemens c9e44c6e0b Bug 31595: Don't process extended attributes if none are inlcuded in the file
This patch simply adds a check to the import process to only process attrbutes if
they have been found in the data

To test:
1 - Import some patrons without extended attributes
2 - Import patrons including extended attributes
3 - Confirm both work unchanged

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 40cff1a774)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4e4fac9314)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-12-16 14:25:25 +01:00
Nick Clemens c5feae38c0 Bug 29561: (follow-up) Don't remove facet '0'
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit c4161b703e)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 6aa1ea5e0c)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-12-14 15:33:27 +01:00
Nick Clemens f62eae0ca6 Bug 29561: Remove blank facets
This patch strips the blank facets from the ES aggregations, this seems
to only affect language fields currently, but could affect any facetable field
that can contain blank values

To test:
1 - Have Koha running Elasticsearch with standard test data,
    or add some records with blank values in the 008/35-37
2 - Search for 'a'
3 - Look at the language facets, they should appear normal
4 - Browse to:
    http://localhost:8081/cgi-bin/koha/catalogue/search.pl?idx=&q=a&sort_by=relevance_dsc&count=20&limit=ln:
5 - Note there is now an 'x' under the Languages facet - to remove a limit you cannot see
6 - Apply patch
7 - Reload
8 - Note the x is not there
9 - Inspect HTML, confirm no blank link under language facets

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit eeb12f8a52)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 3fb3a8c7d6)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-12-14 15:33:27 +01:00
Julian Maurice 1f926a8772 Bug 31441: Fix Koha::Item::as_marc_field when kohafield = ''
marc_subfield_structure.kohafield can be NULL, but it can also be an
empty string. But in that case, Koha::Item::as_marc_field ignores them,
which means the resulting MARC::Field object has missing data.
This can produce a bug in OPAC ISBD view (and probably other places
where this method is used)

Test plan:
1. Edit the default biblio MARC framework for the item field: find or
   create a subfield that is not linked to a DB column.
   Save even if you made no changes to make sure that
   marc_subfield_structure.kohafield is set to an empty string.
   I'll use 995$Z as an example for the following steps.
2. Add the following to syspref OPACISBD:
    #995|<br>Item:|{995Z}|
3. Create a biblio with an item and put a value into 995$Z
4. Go to the ISBD detail page for this record at OPAC. Confirm that the
   value you entered in 995$Z is not visible
5. Apply patch and restart koha
6. Refresh the ISBD detail page. Confirm that the 995$Z is now visible.
7. Run `prove t/db_dependent/Koha/Item.t`

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 389b9dfaf4)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 272510faf7)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-12-14 10:44:49 +01:00
Arthur Suzuki 6045114224 Revert Bug 31421
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-21 10:56:22 +01:00
Tomas Cohen Arazi f9719f7bd8 Bug 29955: Fix method import issues
This patch fixes this:

$ prove t/db_dependent/Utils/Datatables_Virtualshelves.t
t/db_dependent/Utils/Datatables_Virtualshelves.t .. 2/13 Use of inherited AUTOLOAD for non-method Koha::Virtualshelf::haspermission() is no longer allowed at /kohadevbox/koha/Koha/Virtualshelf.pm line 248.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

https://bugs.koha-community.org/show_bug.cgi?id=32080
Signed-off-by: Blou <blou@inlibro.com>

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 432fa9415d)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-15 18:20:09 +01:00
Martin Renvoize 3c00c99508 Bug 31465: (follow-up) Link to preference tabs directly
This patch enhances the mapping system for the help button to allow for
each tab of preferences to link directly to the relevent section of the
manual.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 6d82b66a27)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 78a2c22206)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-15 18:08:58 +01:00
Martin Renvoize b840c1076b Bug 31465: Correct help link for preferences
This patch updates the mapping to reflect the split and rename of the
preferences section of the manual.

Test plan
1) Hitting 'Help' on any tab except for 'Local use' should lead you to
   the globalpreferences section of the manual for your Koha version.
2) Hitting 'Help' on the 'Local use' tab should take you directly to the
   'localusepreferences' manual page.

NOTE: I have now updated the manual build pipeline to remove
renamed/deleted files so prior to this patch you should now see a 404
response when clicking Help from these pages.  Before I made that
change, we had the old file hanging around, so you actually got an
outdated manual page disguised as a more recent version.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 49652f570f)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 2efd39fbda)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-15 18:08:43 +01:00
Tomas Cohen Arazi 8763a3016f Bug 25375: Spelling fixes
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit c20993b945)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 18b81b2de3)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 18:16:23 +01:00
Nick Clemens b70eb7f8b0 Bug 25375: Adjust tests and test itemlost, not notforloan
Previous commit correctly lists Zebra availability test, but was a
bad edit. This fixes the availability test to use itemlost

Additiionally, tests were written before limits were agreed. Adjusted
for the current settings

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 471facdf26)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 544b89cf90)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 18:16:23 +01:00
Nick Clemens 08612d98fc Bug 25375: Match current Zebra availability limit
In Zebra the availability limit code states:
'available' is defined as (items.onloan is NULL) and (items.itemlost = 0)

We should make ES follow the same behaviour so that changing the engine does not
change this.

To test:
1 - Find or create several records with two items each
2 - For those records setup items as:
    a - one checked out, one available
    b - both marked lost
    c - both damaged
    d - both withdrawn
    e - both notforloan
3 - Enable ES and reindex to confirm everything is set
4 - Perform an advanced search to return those records and 'limit to available items'
5 - Confirm you see records b,c,d,e and records say '2 items, none available'
6 - Apply patch
7 - Run `misc/search_tools/rebuild_elasticsearch.pl -d -b`
8 - Perform an advanced search to return those records and 'limit to available items'
9 - Confirm you see records a,b,c,d and al but a say '2 items, none available'

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit b6ace414f7)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 245085d202)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 18:16:23 +01:00
Julian Maurice fd5a9df95b Bug 25375: Add tests for the "available" ES field
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit f48c5bbb8b)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 97b58633d0)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 18:16:23 +01:00
Nick Clemens cb01c54e23 Bug 25375: (QA follow-up) Count available items rather than iterating
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit d9cb39e57d)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4bdaf6b2d1)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 18:16:23 +01:00
Julian Maurice d550066a0f Bug 25375: Get biblionumber from the correct MARC field
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 0ce7293ad5)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 0fa52d7b65)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 18:16:23 +01:00
Julian Maurice fc2a5c514c Bug 25375: Fix 'available' facet in elasticsearch
Add a new boolean ES field named 'available', which is true if at least
one item is available, which means the item is not on loan, not
"notforloan", not withdrawn, not lost and not damaged

A full indexation is required

Test plan:
1. Apply patch and run updatedatabase.pl
2. Run `misc/search_tools/rebuild_elasticsearch.pl -d -b`
3. Make sure you have some biblios whose items are all unavailable, some
   biblios whose items are all available, and some biblios with at least
   one item available and at least one item unavailable
4. Use the 'available' filter on both opac and intranet and make sure it
   works as expected.

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit d79361c51e)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 5a48731b8c)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 18:16:23 +01:00
Marcel de Rooy 3780b27bf6 Bug 31154: (QA follow-up) Fix UI form builder
The change in batchMod.pl is not needed when we fix the builder.
But we could at least add a comment there!

Note that passing the biblionumber of the first item does not
make sense since we are modifying items from several biblio
records normally. We most probably do not want this MARC
record's itemcallnumber (via the syspref) in all our items.

Test plan:
Test batchMod with and without the Populate fields checkbox.
Fill syspref 'itemcallnumber' with e.g. 084a.
Check Populate, and try again.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit eb29243140)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit e5c11f9933)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 17:27:58 +01:00
Jonathan Druart ce924ac297 Bug 31154: Avoid unecessary loop
We don't need to loop over the subfield and enter this block if there is
no record.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit b582f7d495)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 23d0af2eab)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 15:22:24 +01:00
Marcel de Rooy c69c87cb49 Bug 31154: (QA follow-up) Fix UI form builder
The change in batchMod.pl is not needed when we fix the builder.
But we could at least add a comment there!

Note that passing the biblionumber of the first item does not
make sense since we are modifying items from several biblio
records normally. We most probably do not want this MARC
record's itemcallnumber (via the syspref) in all our items.

Test plan:
Test batchMod with and without the Populate fields checkbox.
Fill syspref 'itemcallnumber' with e.g. 084a.
Check Populate, and try again.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit eb29243140)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit e5c11f9933)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 15:22:24 +01:00
Marcel de Rooy f7b1914fc4 Bug 31250: (QA follow-up) The future will be easier
As requested by Jonathan, we need more flexibility ;)
Here it comes.

Test plan:
Run t/CookieManager.t

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

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit cffd36bcb4)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit d865ce1665)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 15:08:08 +01:00
Marcel de Rooy 6b86604469 Bug 31250: Deny clearing cookies with numeric suffix
This change allows us to add catalogue_editor_ to the deny list
in koha-conf.xml and keep cookies like catalogue_editor_123.

Test plan:
Run t/CookieManager.t

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

To test:
1 - Sign in to staff client
2 - Search for records and edit one
3 - Switch to advanced editor
4 - View cookies (F12/developer panel/storage tab)
5 - Note cookie like 'catalogue_editor_##' with value 'advanced'
6 - Log out
7 - note cookie value deleted
8 - Log in and search/edit a record
9 - Basic editor loads
10 - Apply patch
11 - Add line to koha-conf as described in second patch
12 - Restart all
13 - Switch to advanced editor
14 - Cookie value updated
15 - Logout
16 - Cookie value remains
17 - Log in and search/edit
18 - Confirm advanced editor loads

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit cb036faf2c)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 58eb3713ec)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 15:08:08 +01:00
Arthur Suzuki 3e8a4ad176 Bug 30483: DBIC
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 14:59:09 +01:00
Kyle Hall 450872f764 Bug 31401: (QA follow-up) Remove Koha.ArePluginsEnabled, it is no longer needed
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit c5810c3605)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 0c6eef3816)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 14:46:30 +01:00
Nick Clemens 69ac0261a9 Bug 31421: Add a limited option to template plugin
This adds a specific 'limited' routine to the Categories plugin, and uses
it for the new patron dropdowns

To test:
1 - Limit a patron category to some branches
2 - Sign in not at one of those
3 - Confirm the new patron dropdowns don't include the category

Bug 31421: (follow-up) Add POD

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 1fc56e0e47)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit e207c09ee3)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 11:31:42 +01:00
Nick Clemens 9cf7970159 Bug 31421: Do not apply library limits to Categories plugin
This patch simply changes from using 'search_with_library_limits'
to 'search'

The limits I think are intended to prevent users from setting a patron to the wrong category,
they are not meant to hide patrons. Or rather, they don't do that, patrons are returned in search
but cannot be processed. The dropdowns as well won't contain the category, so you can see these
patrons, but not filter by the category

Bug 31422 and bug 31032 point out further issues with limits.

For now, let's fix searching

To test:
1 - Edit Patron category 'Patron/PT'
2 - Try to do a patron search that returns patrons in this category
3 - See 'Processing' and error in JS console: Uncaught TypeError: categories_map[data] is undefined
4 - Apply patch
5 - Restart all and repeate
6 - It works now!

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 29754226ea)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit fbde769aec)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-11-14 11:31:18 +01:00
Nick Clemens 1ea8d99319 Bug 31076: Handle year limits with equal sign or colon
To test:
1 - Enable ES and index
2 - Set expandedSearchOption to 'show'
3 - Advanced search on staff and opac using Year field on staff and Publication date range on OPAC for:
    2005
    2005-
    -2005
    <2005
    >2005
    2005-2010
4 - Confirm ranges don't work on staff side, but do on opac
5 - Apply patch
6 - Repeat searches - they work on both staff and opac
7 - prove t/db_dependent/Koha/SearchEngine/Elasticsearch/QueryBuilder.t

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit a11633379f)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit a72ecc3b27)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-10-19 05:07:19 +02:00
Fridolin Somers 32211362ab Bug 28327: Unify CSV delimiter special behavior for tabulation
System preference 'CSVdelimiter' has a special case for tabulation.
Preference value contains string 'tabulation' but string '\t' must be used in CSV file.

This is OK in many places, for exemple Bug 17590.

This patch adds C4::Context->csv_delimiter to add a uniq metod dealing
with this behavior.
Also create Koha::Template::Plugin::Koha->CSVDelimiter for calls from
Toolkit Templates.

Test plan :
1) Set system preference 'CSVdelimiter' = 'tabs'.
2) Create CSV export in impacted pages
3) Check columns are separated by tabulation character and not string 'tabulation'
4) Check with another delimiter

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 381b79593e)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 9d8ddcc1b7)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-10-19 05:07:19 +02:00
Nick Clemens dd4deaadfc Bug 30779: Remove _update_import_record_marc and update tests
This patch removes the now unused: _update_import_record_marc

Additionally, as items are already present in import biblio we no longer need to embed
them, so that parameter is removed and the option removed from the sub and pod and everywhere
it was used

In all cases, we were embedding, so we don't need a way to get without

Tests updated

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit b02b66acf5)
(cherry picked from commit 54ddc31c71)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-10-12 17:19:57 +02:00
Tomas Cohen Arazi ca7cb4896d Bug 31245: Do not try to report results if task not started
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

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

Signed-off-by: Andrew <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 12bc623ae7)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 3d3fc0f85a)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-10-12 15:54:42 +02:00
Marcel de Rooy 9674c827a9 Bug 27849: (follow-up) Add test
Compacting the code a bit too.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit ad0aa754ee)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 558ee09dd5)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-10-12 15:08:57 +02:00
MJ Ray cb12e41de1 Bug 27849: Koha::Token may access undefined C4::Context->userenv
The _add_default_csrf_params internal function accesses
C4::Context->userenv without checking that it has been defined. I think
not all of the potential callers of it declare that they require a
defined userenv, so we should test and provide defaults for required
values if it is not defined, to avoid some "Can't use an undefined value
as a HASH reference" HTTP 500 Internal Server Errors.

To test:

Do anything that requires a form with CSRF token, such as editing your
details. Behaviour should be unchanged. To test the failure case, you
would need some customised code that indirectly generates a CSRF token
before setting the userenv up and I am not sure there is any in released
Koha yet.

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>

Looks good to me. Working as expected.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 8c45fe1aaa)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit a48cf3c941)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-10-12 15:08:57 +02:00
Arthur Suzuki 837b38217f DBIC
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-10-12 15:06:06 +02:00
Joonas Kylmälä fa0665ad92 Bug 31455: (QA follow-up) Make table creation O(N)
We can insert the indices before the main loop to a hash,
this way we don't have to look up during each loop iteration
the index from an array which in the worst case might take O(N)
thus making the total time complexity O(N^2).

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 223d9d3a99)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit b2a66cd307)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-09-21 11:17:54 +02:00
Arthur Suzuki 594b300bc2 Bug 31086: DBIC
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-09-14 11:36:33 +02:00
Nick Clemens 67513c6562 Bug 31086: Throw an exception when a hold is stored with no branchcode
To test:
1 - Apply first 2 patches
2 - On staff client, find a biblio, place hold, select a patron
3 - Before creating hold, right click on 'Pickup location'
4 - Inspect the element
5 - In the console find the top <li> for pickup, and right click
6 - Select 'Delete node'
7 - Save hold
8 - You get an exception/error

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit e7d886d388)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit e03b542a18)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-09-12 13:52:25 +02:00
Kyle Hall eff7bb8df3 Bug 30458: Include librarian (manager_id) in accountline when using "Payout amount" button
When using the "Payout amount" button, accountlines.manager_id is not
populated. This is not the case with the "Issue payout" buttons.

Test Plan:
1) Create a manual credit
2) Issue a payout using the "Payout amount" button
3) Inspect the payout accountline, note it has no manager_id
4) Apply this patch, restart all the things!
5) Repeat steps 1 and 2
6) Note the new payout accountline has a manager_id!

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
JK: Fix commit title

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 0177b88eb3)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 73f7c89ba6)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-09-12 13:48:21 +02:00
Nick Clemens caea8b048d Bug 30447: Check if transfers arrived or cancelled
TO test:
 1 - Find a bib with a single item
 2 - Browse to Circulation->Transfer
 3 - Transfer the item to another branch
 4 - Check the item in at current branch and cancel the transfer on the dialog
 5 - Place a hold on the biblio for a patron at current branch
 6 - Browse to Circulation->Holds to pull
 7 - Item does not show
 8 - Apply patch, restart all
 9 - Browse to Circulation->Holds to pull
10 - Item shows

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 206ba015c4)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 3f7363f6ca)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-08-26 15:06:47 +02:00
Shi Yao Wang b30ad9a54e Bug 29922: Make get_search_groups return results sorted by title
get_search_groups from Koha/Library/Groups.pm returns library groups sorted by title.

Test plan:
1- Go to administration > library groups and create multiple library groups with different names (e.g. AGroup, BGroup, ÄGroup, etc.). Make sure to tick "Use for OPAC search groups" checkbox.
2- Go to advanced search in OPAC.
3- Under "Groups of librairies" , click the select button.
4- Notice that the library groups are not in alphabetical order.
5- Apply the patch.
6- Notice that the library groups are in alphabetical order.
7- Run `prove t/db_dependent/LibraryGroups.t` and all test should pass.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit d86d949551)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 73d5fd08f5)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-08-26 15:02:30 +02:00
Martin Renvoize 731c9dd7c9 Bug 29105: Add effective_itemtype handling to items api
This patch adds effective_item_type_id to the items api.

We overload the to_api method to append the effective_item_type_id field
with that of the effective itemtype code.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit dc75b5d5cd)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit f00a28b576)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
2022-08-26 14:47:57 +02:00