This patch adds unit tests for the new to_json method being introduced
in Koha::Edifact module in the next patch.
The tests verify:
- JSON output generation and validity
- Proper structure with header, messages, and trailer fields
- Message array structure with correct number of messages
- Individual message structure (header, segments, trailer)
- Segment data integrity including raw data and elements arrays
- Line ID functionality for related segments (LIN, QTY, PRI, PIA)
Test plan:
1. Apply this patch and the next one
2. Run: prove t/Edifact.t
3. Verify all 63 tests pass
4. Confirm the new JSON-related tests (22 tests) execute successfully
Sponsored-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This patch clarifies which records will be deleted in
the batch item deletion (when no items remain).
Test plan:
0. Apply the patch
1. Go to "Reports" and click "Create from SQL"
2. Create a report with the following SQL:
select itemnumber from items limit 5
3. Run the report and then click "Batch operations with 5 visible records"
on the output page
4. Near the bottom of the screen note that there is a checkbox that
has a label reading "Delete bibliographic records if no items remain."
5. C'est tout!
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Test plan
=========
1. Make field 026 active for Editor in MARC framework section (e.g. in default
framework).
2. Edit any bibliographic record (with modified framework) adding 026 field data,
e.g. 026 ## $a urdu esrt $b eses jecl $c 1790
3. Verify in Normal view (intranet) and in OPAC that you are unable to
see the inserted data.
4. Apply the patch ; restart_all.
5. Verify in Normal view (intranet) and in OPAC that you are now able to
see the fingerprint information from 026 field.
Sponsored-by: Ignatianum University in Cracow
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Libraries cataloguing older monographic resources request fingerprint indexing.
In MARC 21, it would be the content of field 026, in UNIMARC - 012.
Test plan
=========
1. Start up KTD with Elasticsearch: ktd --search-engine es8 up -d
2. Make field 026 active for Editor in MARC framework section (e.g. in default
framework).
3. Edit any bibliographic record (with modified framework) adding 026 field data,
e.g. 026 ## $a urdu esrt $b eses jecl $c 1790
4. Verify that you are unable to find the record searching with fingerprint data.
5. Apply the patch ; restart_all.
6. Reindex with: koha-elasticsearch --rebuild -r -d kohadev
7. Now you should be able to find the record searching with fingerprint data
(performing a general search or prefixed with 'fingerprint-identifier:').
Sponsored-by: Ignatianum University in Cracow
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This patch changes the way the notices template checks for the existence
of the TranslateNotices system preference in order to avoid a missing
space in the corresponding label.
To test you should have at least two languages enabled under the
StaffInterfaceLanguages system preference.
- Apply the patch and go to Administration -> System preferences..
- Locate the TranslateNotices preference and set it to "Allow"
- Go to Tools -> Notices and edit a notice.
- The "Modify notice" page should have tabs each of your enabled
languages as well as "Default."
- Each tab should have a "Format" section. Expand it and check that the
label for the checkbox at the bottom is correct, e.g. "Apply format
settings to all notices for this language."
- Return to system preferences and set TranslateNotices to "Don't
allow."
- Reload the notice edit screen and check the "Format" section. The
label should now read "Apply format settings to all notices."
Sponsored-by: Athens County Public Libraries
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Test plan:
==========
1. Have a ktd instance with Elasticsearch enabled.
2. In standard ktd installation there is a record with a title
"Typical girls? : the story of the Slits." (with question mark
attached to a word) - biblio # 229. We will try to find it.
3. Go to advanced search (OPAC or intranet) and try a *title* search
with:
Typical girls? the story of the Slits
You should get no results.
From the main page try a ccl-style search:
ti:Typical girls? the story of the Slits
You should get no results too.
4. Apply the patch ; updatedatabase ; restart_all.
5. Put ? in OpacElasticsearchEscapeCharacters and/or
ElasticsearchEscapeCharacters system preference.
4. Repeat the searches from p. 3. You should get the record if a
system preference was set for the given interface.
Sponsored-by: Pontificia Università di San Tommaso d'Aquino (Angelicum)
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
To test: prove t/db_dependent/Reserves.t
Signed-off-by: Emmanuel Bétemps <e.betemps@gmail.com>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
When logging a hold create action, include all hold fields that may be
defined at hold creation.
Fields that are not defined until later (such as found status, waiting
date, etc) are not included to avoid clutter.
To test:
1. System preference setup
i. Enable HoldsLog system preference
ii. Set AllowHoldPolicyOverride to Allow
2. Place a hold in the staff interface
3. View the action logs entry for that hold creation
i. Go to Tools > Log viewer
ii. Select Modules: Holds and Action: Create
iii. Click Submit
--> Note that the "info" column only shows the hold id
4. Apply patch and restart_all
5. Repeat steps 2-3
--> The "info" column should now show hold details
Signed-off-by: Emmanuel Bétemps <e.betemps@gmail.com>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Fix spelling on the SIP2 account form to spell 'Syspref'
section heading in full ('System preference overrides').
Test plan:
1. Go to Administration > Patrons and circulation > Self-service
circulation (SIP2) > Accounts > New account
2. Note the label for the section is "Syspref overrides".
3. Apply the patch.
4. Rebuild everything: yarn build
5. Hard refresh the page.
6. Note that "Syspref..." is now spelt in full as
"System preference overrides".
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Anneli Österman <anneli.osterman@koha-suomi.fi>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
- Add aria-label="Quick shortcuts" to the shortcut nav element
in both the TT include and the Vue Help component
- Ensures all nav landmarks on the staff interface are
uniquely labeled for screen readers (WCAG 2.4.1)
To test:
- Apply the patch
- Rebuild vue components with `yarn js:build`
- Open the staff interface home page
- View the page source and confirm the shortcut nav has
aria-label="Quick shortcuts"
- Confirm that all three nav elements (Main, Breadcrumb,
Quick shortcuts) have unique aria-labels
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
The main <nav> should have a unique aria-label to differentiate it from the Breadcrumb nav
To test:
1. View page source and confirm there are two <nav> elements
2. Notice the main <nav> does not have a unique aria-label
3. Apply patch and check again
4. Confirm the main <nav> is labeled
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This patch imporves accessibility for screen readers by removing a duplicate empty link
that is rendered in the breadcrumbs on patron pages.
patron-title.inc already includes the links and doesn't need to be wrapped in <a> element.
To test:
1. Go to a patron record and tab through the breadcrumbs
2. Notice there is an empty link that is invisible but gets focus
between the Patrons and <patron title> breadcrumbs.
3. Check the other tabs to confirm the issue is present
Accounting, Routing list, Circulation history, Holds history, Notices,
Statistics and Purchase suggestions
4. Click edit and check the breadcrumbs on that page
5. Enable TwoFactorAuthentication and check the manage two-factor auth page
6. Apply patch
7. Revist the pages from steps 1-5 and tab through the breadcrumbs again
8. Confirm there is no duplicate empty link
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
- Add order_by => ['name'] to record_sources fetch in marc-overlay-rules.pl
so filter dropdown options are consistently sorted
- Add COMMENT to record_sources.is_system column in kohastructure.sql
to match convention of other columns in that table
- Remove commented-out Data::Dumper debug lines from biblios.t
- Remove redundant explicit object deletes inside subtests that are
already wrapped in txn_rollback; the rollback undoes them anyway
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
INSERT IGNORE silently skips rows whose name already exists, leaving
their is_system column at 0. Systems that already had 'intranet',
'z3950' etc. as record sources would not have them protected from
deletion. Added an explicit UPDATE after the INSERT to ensure all
known system record source names have is_system=1 regardless of
whether the row was just inserted or already existed.
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
The CASE checks for 'bulkmarkimport' but the record source inserted by
the atomicupdate is named 'bulkmarcimport'. The mismatch caused the
display label and the JS filter option to fall through to the default
(untranslated) case. Fixed in both the rule filter display block and the
module_filter_options JS object.
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Make atomicupdate script executable, add html filters to tt, annotate is_system as boolean (SQL12 coding guidelines)
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
updateBiblio API:
- tests for locked records (records with a given record_source which is set to can_be_edited = 0)
- tests for MARCOverlayRules bound to a record_source or fallback source (*)
As record_sources now has an is_system property which prevents it from getting deleted, all tests creating and deleting a record_source were changed so that is_system is set to 0 on creation.
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This patch moves hardcoded source filter from 'MARC overlay rules' (batchmod, intranet, z3950, staged import, bulk import, import_lexile) to 'Record Sources' and makes them untouchable. They cannot be renamed or modified.
New record sources can be added and modified though.
All default and newly created record sources are available as filter for the module "Source" in 'MARC overlay rules'.
The API route for PUT /biblios/:biblio_id now checks for a given header x-record-source-id.
If an id is given the name of the rule is retrieved and forwarded as an overlay_context to ModBiblio.
If no id is given the fallback '*' is added as overlay_context.
Also the record source id is getting saved.
Test plan:
pre) run perl installer/data/mysql/updatedatabase.pl to add new is_system column
pre) run dbic to build Koha::Schema::Result::RecordSource as it gets a new columns is_system
pre) run 'redocly bundle --ext json api/v1/swagger/swagger.yaml --output api/v1/swagger/swagger_bundle.json' or 'yarn build'
a) enable system preference MARCOverlayRules and RESTBasicAuth
b) create new record source in /cgi-bin/koha/admin/record_sources and recognize its <NAME> and <ID>
c) create overlay rules in /cgi-bin/koha/admin/marc-overlay-rules.pl
f.e.
+----+-----+--------+----------+-----------+
| id | tag | module | filter | preset |
+----+-----+--------+----------+-----------+
| 1 | 245 | source | * | protect |
+----+-----+--------+----------+-----------+
This will make the 245 field protected from change, unless the record source matches
d) go to /cgi-bin/koha/catalogue/detail.pl?biblionumber=262 and change 245 (title) via edit -> edit record
e) save and take a look the title is still the same
f) run the updateBiblio-Request from below with a API-testing client like REST Client
g) check that title gets overwritten even though it is protected. This is due the fact the updateBiblio is not setting an overlay context.
h) apply patch
redo d) and e)
i) add another overlay rule allowing your record source to change 245:
+----+-----+--------+----------+-----------+
| id | tag | module | filter | preset |
+----+-----+--------+----------+-----------+
| 1 | 245 | source | * | protect |
| 2 | 245 | source | <NAME> | overwrite |
+----+-----+--------+----------+-----------+
j) run the updateBiblio-Request from below, be sure to fill out x-record-source-id:with your ID from step b)
k) check that title gets overwritten
l) run the updateBiblio-Request from below, but omit x-record-source-id or set it to another value than <ID>
m) check that title is not overwritten
PUT http://main-intra.localhost/api/v1/biblios/262
Authorization: Basic koha:koha
Authorization: Basic koha:koha
Content-Type: application/marcxml+xml
x-record-source-id: <ID>
<?xml version="1.0" encoding="UTF-8"?>
<record
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.loc.gov/MARC21/slimhttp://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
xmlns="http://www.loc.gov/MARC21/slim">
<leader>01075cam a2200313 a 4500</leader>
<controlfield tag="001">foo</controlfield>
<controlfield tag="005">20200421093825.0</controlfield>
<controlfield tag="008">120417s2012 ch a b 001 0 eng </controlfield>
<datafield tag="040" ind1=" " ind2=" ">
<subfield code="c">482</subfield>
</datafield>
<datafield tag="100" ind1="1" ind2=" ">
<subfield code="a">Christiansen, Tom.</subfield>
<subfield code="9">482</subfield>
</datafield>
<datafield tag="245" ind1="1" ind2="0">
<subfield code="a">New Title</subfield>
<subfield code="c">Tom Christiansen, Brian D. Foy & Larry Wall.</subfield>
</datafield>
<datafield tag="260" ind1=" " ind2=" ">
<subfield code="a">City</subfield>
</datafield>
<datafield tag="300" ind1=" " ind2=" ">
<subfield code="a">Pages and more</subfield>
</datafield>
<datafield tag="942" ind1=" " ind2=" ">
<subfield code="c">BKS</subfield>
</datafield>
</record>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This patch enhances the filters in record overlay rules when using the "Source" module. The available filter values are now system defined in Administration -> Record sources and can be extended by own record souces. The former hard coded values (f.e. batchmod, intranet) are added to the database and cannot be deleted.
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This changes the structure of record source with an is_system column which controls whether this value can be deleted.
Also predefined values are inserted to reflect the default hard coded values from 'Record overlay rules' sources
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
mock_userenv expects 'branchcode' but the test was passing 'branch',
causing the branchcode to fall through to the 'Branch4T' default and
the branch-specific notice lookup to never match.
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Koha::Object::AUTOLOAD calls set_column directly, bypassing DBIC's
inflate/deflate mechanism. This means date/datetime column values set
via Koha object accessors (without store()) can end up as raw DateTime
objects in _column_data. When _unblessed_for_log then calls get_column,
it retrieves the DateTime object, which encode_json in C4::Log cannot
serialise, causing the patron delete (and test) to die with an
"encountered object" error.
Fix by stringifying any DateTime objects found in the column data before
returning from _unblessed_for_log.
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
mock_userenv was called before the test patron was created and
used the default borrowernumber (51), which doesn't necessarily
exist in the test database. This caused safe_to_delete to crash
on the not_same_branch check when Koha::Patrons->find returned
undef.
Move mock_userenv after patron creation and pass the actual
borrowernumber.
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Switch from unblessed() to get_column() so that date/datetime column
values are returned as raw ISO strings directly from DBIC's internal
storage, without constructing DateTime objects that would only be
immediately stringified. This makes _unblessed_for_log cheaper on every
call, which is particularly noticeable in the test suite where
BorrowersLog defaults to enabled and patron stores are frequent.
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This adds a new system preference to control the amount of boost. The default of 0 will act as before this patch.
You can add any positive number, or a number between 0 and 1 for negative boost
To test:
1 - Add a record with
245 $a novel
2 - Add a record with
245 $a A novel : $b about things / $c by me
3 - Search for: novel
4 - Search for: a novel
5 - Apply patch, restart all
6 - Repeat searches, note exact titles are boosted
7 - Test with more titles as you are able
Signed-off-by: Jason Robb <jrobb@sekls.org>
Signed-off-by: Thomas Klausner <domm@plix.at>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Jason Robb <jrobb@sekls.org>
Signed-off-by: Thomas Klausner <domm@plix.at>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
- Fix potential crash when C4::Context->userenv returns undef:
use the established ternary guard pattern used throughout other
TT plugins (AuthorisedValues, Branches, Desks, etc.)
- Remove dead second argument passed to GetLettersAvailableForALibrary,
which only accepts one argument; the group_by/columns/order_by
hashref was silently dropped
- Fix typo "librries" -> "libraries" in GetByModuleForLibrary POD
- Update POD example to use 'add_message' module matching actual usage
- Add test coverage for GetByModuleForLibrary, verifying that a user
logged in to a branch sees branch-specific and all-libraries notices,
while users at other branches see only all-libraries notices
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
To test
The following should work with either email or SMS notices sent from the Add Message button in a patron record
1 - create a notice in module Patrons (custom message) for all libraries
2 - create a notice in module Patrons (custom message) for Centerville
3 - while logged in at Centerville, confirm you can see and enqueue your all libraries message
4 - while logged in at Centerville, confirm you can see but cannot successfully enqueue your Centerville message
5 - while logged in at Fairfield, confirm you can see but cannot successfully enqueue your Centerville message
6 - apply patch, restart_all
7 - while logged in at Fairfield, confirm you can see and enqueue your all libraries message
8 - while logged in at Fairfield, confirm you cannot see your Centerville message
9 - while logged in at Centervielle, confirm you can see and enqueue your Centerville message
Signed-off-by: Juliet Heltibridle <jheltibridle@rcplib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Replace the O(n²) accumulate-and-re-insert pattern with a simple
per-row execute inside the while loop.
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
To test:
1 - have an staff account with 'send_messages_to_borrowers' permission but not top level 'borrowers' permission
2 - have a value in SMSSendDriver system preference
3 - log in under your staff account and confirm you can send both email and SMS messages from the Add Message button on a patron record
4 - apply patch, updatedatabase, restart_all
5 - confirm your staff account now has 'send_messages_to_borrowers_email' permission rather than 'send_messages_to_borrowers'
6 - confirm your staff account can now only send email messages from the Add Message button on a patron record
7 - add 'send_messages_to_borrowers_sms' permission to your staff account
8 - confirm your staff account can now send both email and sms messages from the Add Message button on a patron record
9 - remove 'send_messages_to_borrowers_email' from your staff account
10 - confirm your staff account can now only send sms messages from the Add Message button on a patron record
Signed-off-by: Juliet Heltibridle <jheltibridle@rcplib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Bug 20253 introduced the ability to use the basket name as a purchase order
number in the BGM segment of an EDIFACT order message. However, the basket
name was inserted into the BGM segment without escaping EDIFACT special
characters (apostrophe, colon, plus, question mark).
In EDIFACT, the apostrophe (') is the segment terminator, so any literal
apostrophe in data must be escaped with the release character (?) as ?'.
Without this, a basket name like "Children's Requests" would produce an
invalid EDIFACT message.
This fix applies encode_text() to the purchase order number in
beginning_of_message() so all special characters are properly escaped.
Test plan:
- Run t/db_dependent/Koha/Edifact/Order.t
- All tests should pass, including the new tests covering special character
escaping in BGM segments
Signed-off-by: Graham Jones <GrahamJ@askewsandholts.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>