From f095a2f2d1b3f3afeb7b1bc7253f5b274d79f53b Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 6 Jun 2023 14:59:47 -0300 Subject: [PATCH 01/19] Increment version for Koha 21.11.21-1 release Signed-off-by: Tomas Cohen Arazi --- installer/data/mysql/db_revs/211121000.pl | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 installer/data/mysql/db_revs/211121000.pl diff --git a/installer/data/mysql/db_revs/211121000.pl b/installer/data/mysql/db_revs/211121000.pl new file mode 100755 index 0000000000..2fda5dddc2 --- /dev/null +++ b/installer/data/mysql/db_revs/211121000.pl @@ -0,0 +1,8 @@ +use Modern::Perl; + +return { + bug_number => undef, + description => 'Koha 21.11.21 release', + up => sub {}, +} + From ba3efc157d87a357f9199342cadc393798c0b043 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 9 Jun 2023 14:40:42 -0300 Subject: [PATCH 02/19] Revert "Bug 30352: Add a comment to the substatus translation" This reverts commit 277e13eda122fe259a2b45726a5bf607d52785d3. Signed-off-by: Tomas Cohen Arazi --- .../opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl index c9356a88ae..8224194060 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl @@ -1313,7 +1313,6 @@ - @@ -1355,7 +1354,7 @@ : - + @@ -1374,7 +1373,7 @@ - + From faf8ebe382159ccbe93bbc59ec2edb5aa4bae96b Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 9 Jun 2023 14:40:48 -0300 Subject: [PATCH 03/19] Revert "Bug 30352: Allow translation of Not for loan in OPAC XSLT results" This reverts commit 98a575fcff1d1d689dcbf2462adc4ca70086f0ec. Signed-off-by: Tomas Cohen Arazi --- .../en/xslt/MARC21slim2OPACResults.xsl | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl index 8224194060..59a2caba55 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl @@ -1310,10 +1310,7 @@ - - - - + @@ -1334,7 +1331,6 @@ Pending hold In transit On hold - Not for loan @@ -1354,7 +1350,12 @@ : - + + + + + + @@ -1373,7 +1374,12 @@ - + + + + + + From 90344b34394e7a68ccc58126f270189c169f82e3 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 9 Jun 2023 15:17:08 -0300 Subject: [PATCH 04/19] Increment version for Koha 21.11.22 release Signed-off-by: Tomas Cohen Arazi --- Koha.pm | 2 +- installer/data/mysql/db_revs/211122000.pl | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/db_revs/211122000.pl diff --git a/Koha.pm b/Koha.pm index 4c8120c217..98ead88d8b 100644 --- a/Koha.pm +++ b/Koha.pm @@ -29,7 +29,7 @@ use vars qw{ $VERSION }; # - #4 : the developer version. The 4th number is the database subversion. # used by developers when the database changes. updatedatabase take care of the changes itself # and is automatically called by Auth.pm when needed. -$VERSION = "21.11.21.000"; +$VERSION = "21.11.22.000"; sub version { return $VERSION; diff --git a/installer/data/mysql/db_revs/211122000.pl b/installer/data/mysql/db_revs/211122000.pl new file mode 100755 index 0000000000..36760bc8e2 --- /dev/null +++ b/installer/data/mysql/db_revs/211122000.pl @@ -0,0 +1,8 @@ +use Modern::Perl; + +return { + bug_number => undef, + description => 'Koha 21.11.22 release', + up => sub {}, +} + From 07130050a1d0dec3bb0d399d49f82b5c23928311 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 9 Jun 2023 15:37:19 -0300 Subject: [PATCH 05/19] db_revs fixes Signed-off-by: Tomas Cohen Arazi --- installer/data/mysql/db_revs/211112000.pl~ | 7 ------- installer/data/mysql/db_revs/211120000.pl | 0 2 files changed, 7 deletions(-) delete mode 100755 installer/data/mysql/db_revs/211112000.pl~ mode change 100644 => 100755 installer/data/mysql/db_revs/211120000.pl diff --git a/installer/data/mysql/db_revs/211112000.pl~ b/installer/data/mysql/db_revs/211112000.pl~ deleted file mode 100755 index 212549da1f..0000000000 --- a/installer/data/mysql/db_revs/211112000.pl~ +++ /dev/null @@ -1,7 +0,0 @@ -use Modern::Perl; - -return { - bug_number => undef, - description => 'Koha 21.11.12 release', - up => sub {}, -} diff --git a/installer/data/mysql/db_revs/211120000.pl b/installer/data/mysql/db_revs/211120000.pl old mode 100644 new mode 100755 From 92e6c8029ad4a5e001ec74a48e1a498691132094 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 16 Nov 2021 09:13:30 +0100 Subject: [PATCH 06/19] Bug 29486: _koha_marc_update_bib_ids no longer needed for GetMarcBiblio This subroutine is ensuring that the biblionumber and biblioitemnumber will be part of the MARC record. We should not need that, unless there is something broken somewhere else. This line has been added by the following commit: commit 4e95e94727b09b33d2f6c597bdd218a59dcc3681 Bug 6789: biblios with many items can result in broken search results link """ To this end, it also moves the fix_biblio_ids portion of get_corrected_marc_record out of rebuild_zebra.pl, and makes it a part of GetMarcBiblio (right before EmbedItemsInMarcBiblio, so the 952s still come last). fix_biblio_ids is kept as a subroutine for the deletion portion of rebuild_zebra.pl, which still uses it. """ But it does not explain why it's better to have it in GetMarcBiblio. If we need it for the reindexation process, we shouldn't impact GetMarcBiblio which is used from several different places. We might then consider adding the fix_biblio_ids call to rebuild_zebra.pl, but I am failing to understand in which cases it could be useful. Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers Signed-off-by: Tomas Cohen Arazi --- C4/Biblio.pm | 8 -------- 1 file changed, 8 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index b5c870d635..7920bb3047 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1218,14 +1218,8 @@ sub GetMarcBiblio { return; } - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=? "); - $sth->execute($biblionumber); - my $row = $sth->fetchrow_hashref; - my $biblioitemnumber = $row->{'biblioitemnumber'}; my $marcxml = GetXmlBiblio( $biblionumber ); $marcxml = StripNonXmlChars( $marcxml ); - my $frameworkcode = GetFrameworkCode($biblionumber); MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); my $record = MARC::Record->new(); @@ -1237,8 +1231,6 @@ sub GetMarcBiblio { if ($@) { warn " problem with :$biblionumber : $@ \n$marcxml"; } return unless $record; - C4::Biblio::_koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber, - $biblioitemnumber ); C4::Biblio::EmbedItemsInMarcBiblio({ marc_record => $record, biblionumber => $biblionumber, From 3e595bcec0654533ec02bd7f5413e26a62f9370d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 19 Jan 2022 14:39:51 +0100 Subject: [PATCH 07/19] Bug 29486: Fix tests Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Biblio.t | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index b3d971d833..ff0857a296 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -420,8 +420,6 @@ sub run_tests { is( GetMarcPrice( $record_for_isbn, $marcflavour ), 100, "GetMarcPrice returns the correct value"); - my $newincbiblioitemnumber=$biblioitemnumber+1; - $dbh->do("UPDATE biblioitems SET biblioitemnumber = ? WHERE biblionumber = ?;", undef, $newincbiblioitemnumber, $biblionumber ); my $updatedrecord = GetMarcBiblio({ biblionumber => $biblionumber, embed_items => 0 }); @@ -434,7 +432,6 @@ sub run_tests { } else { $biblioitemnumbertotest = $updatedrecord->field($biblioitem_tag)->subfield($biblioitem_subfield); } - is ($newincbiblioitemnumber, $biblioitemnumbertotest, 'Check newincbiblioitemnumber'); # test for GetMarcUrls $marc_record->append_fields( @@ -597,14 +594,14 @@ sub create_author_field { } subtest 'MARC21' => sub { - plan tests => 47; + plan tests => 46; run_tests('MARC21'); $schema->storage->txn_rollback; $schema->storage->txn_begin; }; subtest 'UNIMARC' => sub { - plan tests => 47; + plan tests => 46; # Mock the auth type data for UNIMARC $dbh->do("UPDATE auth_types SET auth_tag_to_report = '106' WHERE auth_tag_to_report = '100'") or die $dbh->errstr; From 01bba470680debe405f43b96d0891c5a93cc88a7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 19 Jan 2022 14:40:14 +0100 Subject: [PATCH 08/19] Bug 29486: Add check in search_for_data_inconsistencies.pl If the MARC record does not contain the correct biblionumber of biblioitemnumber, the script will display the following warning: == Bibliographic records have MARCXML without biblionumber or biblioitemnumber == * Biblionumber 4242 has '1' in 999$c * Biblionumber 4242 has biblioitemnumber '4242' but should be '1' in 999$d => The bibliographic records must have the biblionumber and biblioitemnumber in MARCXML Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers Signed-off-by: Tomas Cohen Arazi --- .../search_for_data_inconsistencies.pl | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/misc/maintenance/search_for_data_inconsistencies.pl b/misc/maintenance/search_for_data_inconsistencies.pl index c2c94d490c..8a7309208f 100755 --- a/misc/maintenance/search_for_data_inconsistencies.pl +++ b/misc/maintenance/search_for_data_inconsistencies.pl @@ -118,8 +118,10 @@ use C4::Biblio qw( GetMarcFromKohaField ); } } - my @decoding_errors; + my ( @decoding_errors, @ids_not_in_marc ); my $biblios = Koha::Biblios->search; + my ( $biblio_tag, $biblio_subfield ) = C4::Biblio::GetMarcFromKohaField( "biblio.biblionumber" ); + my ( $biblioitem_tag, $biblioitem_subfield ) = C4::Biblio::GetMarcFromKohaField( "biblioitems.biblioitemnumber" ); while ( my $biblio = $biblios->next ) { my $record = eval{$biblio->metadata->record;}; if ($@) { @@ -160,6 +162,33 @@ use C4::Biblio qw( GetMarcFromKohaField ); new_item($_) for @decoding_errors; new_hint("The bibliographic records must have a valid MARCXML or you will face encoding issues or wrong displays"); } + if (@ids_not_in_marc) { + new_section("Bibliographic records have MARCXML without biblionumber or biblioitemnumber"); + for my $id (@ids_not_in_marc) { + if ( exists $id->{biblioitemnumber} ) { + new_item( + sprintf(q{Biblionumber %s has biblioitemnumber '%s' but should be '%s' in %s$%s}, + $id->{biblionumber}, + $id->{biblioitemnumber}, + $id->{biblioitemnumber_in_marc}, + $biblioitem_tag, + $biblioitem_subfield, + ) + ); + } + else { + new_item( + sprintf(q{Biblionumber %s has '%s' in %s$%s}, + $id->{biblionumber}, + $id->{biblionumber_in_marc}, + $biblio_tag, + $biblio_subfield, + ) + ); + } + } + new_hint("The bibliographic records must have the biblionumber and biblioitemnumber in MARCXML"); + } } { From d5a1f3b419b51bf844d7b8739ce7252866f7c3aa Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Sun, 5 Feb 2023 00:17:01 +0000 Subject: [PATCH 09/19] Bug 31410: Set focus for cursor to Server name when adding a new Z39.50/SRU server This makes sure that the focus is in the first form field when adding a new Z39.50 or SRU server. To test: * Administration > Z39.50/SRU servers * Add a new server for each * Verify the focus is not in the form * Apply patch * Verify the focus is now in the first form field * Edit an existing server * Verify the focus is not in the form Not having the focus when editing is to avoid accidental changes. Signed-off-by: Owen Leonard Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 2504a282b5890168616c1a87206f8762c38a660d) Signed-off-by: Martin Renvoize (cherry picked from commit 71f20a1c3513759393a9bae3654eb295fcb4016e) Signed-off-by: Lucas Gass (cherry picked from commit ee095916fc0b94bf2e50a277fa6b188c72598246) Signed-off-by: danyonsewell (cherry picked from commit ee095916fc0b94bf2e50a277fa6b188c72598246) --- .../intranet-tmpl/prog/en/modules/admin/z3950servers.tt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt index 585e6bc86b..889c4e2d08 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt @@ -95,7 +95,12 @@
  1. - Required + [% IF server.servername %] + + [% ELSE %] + + [% END %] + Required
  2. Required From cc096b62df1dbde30a43a793e34411eb05fb92a2 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Sat, 4 Feb 2023 23:54:22 +0000 Subject: [PATCH 10/19] Bug 31405: Set focus for cursor to setSpec input when adding a new OAI set Makes sure the focus is in the first form field when adding a new OAI set: setSpec To test: * Go to administration > OAI sets * Add a new set, verify the focus is still in the search bar on top * Apply patch * Repeat and verify the focus is now in the first form field * Save set * Edit set and verify the focus is in the search field at the top Signed-off-by: Owen Leonard Signed-off-by: David Nind Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 5a5034792c5269ef11f2acddd3d6055886cded06) Signed-off-by: Martin Renvoize (cherry picked from commit b9abcea244ecc43762fab6a607ea3564b2da1291) Signed-off-by: Lucas Gass (cherry picked from commit 7c94ccd664cd7162d3c20229c7eb4cc5bc5ee4c5) Signed-off-by: danyonsewell (Cherry picked from commit 7c94ccd664cd7162d3c20229c7eb4cc5bc5ee4c5) --- koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt index a433a8c10b..44a14f9354 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt @@ -72,7 +72,11 @@
    1. - + [% IF ( spec == "" ) %] + + [% ELSE %] + + [% END %] Required
    2. From e9ba6ed0dfdd7d17de2d92b041a6993a91215822 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Fri, 17 Mar 2023 22:42:47 +0000 Subject: [PATCH 11/19] Bug 33196: Generalize pseudonymization system preference description The Pseudonymization system preference description in the staff interface is: "Disable/Enable pseudonymization to comply with GDPR for personal information. Patrons and transactions will be copied to a separate table for statistics purpose." GDPR is a European Union (and, at time of writing, UK) law; it makes the system preference look irrelevant for libraries outside this area. However, this is not correct: pseudonymization may be useful for libraries anywhere. This generalized the system preference description and only uses GDPR as an example instead of the only purpose. It also updates the fields listed to more closely reflect the labels on the patron form. To test: * Search for "Pseudonymization" in the systme preferences * Verify that the description of the system preference is very GDPR * Apply patch * Verify the system preference description is improved https://bugs.koha-community.org/show_bug.cgi?id=33196 Signed-off-by: David Nind Signed-off-by: Lucas Gass Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 54cdae763365636e71a231432d5afff637796963) Signed-off-by: Martin Renvoize (cherry picked from commit b6a8c6ce59173ab95494a8a1571c55591af4c59a) Signed-off-by: Lucas Gass (cherry picked from commit d0b05432a85c380df72e9e6ffefe37573944a658) Signed-off-by: danyonsewell (cherry picked from commit d0b05432a85c380df72e9e6ffefe37573944a658) --- .../prog/en/modules/admin/preferences/patrons.pref | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index 787477b7f1..26942043de 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -376,22 +376,22 @@ Patrons: choices: 1: Enable 0: Disable - - "pseudonymization to comply with GDPR for personal information." - - "Patrons and transactions will be copied to a separate table for statistics purpose." + - "pseudonymization to comply with data privacy policies and regulations like GDPR for managing personal information." + - "Patrons and transactions will be copied to a separate table for statistical purposes." - "
      Use the following fields for patrons:" - pref: PseudonymizationPatronFields multiple: title: "Patron's title" city: "City" state: "State" - zipcode: "Zipcode" + zipcode: "ZIP/Postal code" country: "Country" branchcode: "Patron's library" - categorycode: "Patron's category" + categorycode: "Patron category" dateenrolled: "Date the patron was added to Koha" sex: "Patron's gender" - sort1: "Sort1" - sort2: "Sort2" + sort1: "Sort 1" + sort2: "Sort 2" - "
      And the following fields for the transactions:" - pref: PseudonymizationTransactionFields multiple: From 2b57946d04764723ccc01df869d3f21a50037d73 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 2 May 2023 00:16:30 +0000 Subject: [PATCH 12/19] Bug 33645: Make koha-foreach return 0 if it completes successfully This patch adds an "exit 0" to the end of koha-foreach, so that it returns a successful exit code if it reaches the bottom of the script without errors. Test plan: 0) `koha-foreach echo` 1) `echo $?` 2) Note that the exit status is 1 3) Apply patch 4) `./debian/scripts/koha-foreach echo` 5) `echo $?` 6) Note that the exit status is 0 Signed-off-by: David Nind Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi (cherry picked from commit e8a187eb7422419592899ea12903f9ff29f96cfd) Signed-off-by: Martin Renvoize (cherry picked from commit ef3985df0673304117f8c90fc673482d81410c06) Signed-off-by: Lucas Gass (cherry picked from commit 9f8b34e8d6b28400e38b89301cb72e0c31920c40) Signed-off-by: danyonsewell (cherry picked from commit 9f8b34e8d6b28400e38b89301cb72e0c31920c40) --- debian/scripts/koha-foreach | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian/scripts/koha-foreach b/debian/scripts/koha-foreach index 2f5a150fcb..d2e98dd7de 100755 --- a/debian/scripts/koha-foreach +++ b/debian/scripts/koha-foreach @@ -72,3 +72,5 @@ do [ "$chdir" != "no" ] && cd "$starting_dir" fi done + +exit 0 From 011085eebb1e0ba19c729b1629db42e00eacaef5 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 11 Apr 2023 20:41:28 +0000 Subject: [PATCH 13/19] Bug 33233: Don't allow disabled attribute to remain when using browser's back button To test: 1. Go to OPAC advanced search and do a search using only one of the inputs. 2. Once the search is complete use the browser's back button to return to the advanced search. 3. Notice the unused inputs are disabled. 4. Apply patch and try again. Now the inputs should not be disabled. Signed-off-by: Barbara Johnson Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 3811bb4381e34db7da1fd4593560fef519c4fde4) Signed-off-by: Martin Renvoize (cherry picked from commit c9b0106bd9d24ac7d11529023630f801284cd63b) Signed-off-by: Lucas Gass (cherry picked from commit 06bf531b3d6d9fdf27499d8a0b1361d798c74193) Signed-off-by: danyonsewell (cherry picked from commit 06bf531b3d6d9fdf27499d8a0b1361d798c74193) --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt index cd21067de1..aae1ef2138 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt @@ -450,6 +450,9 @@ [% BLOCK jsinclude %] [% Asset.js("lib/jquery/plugins/jquery.deserialize.min.js") | $raw %] [% END %] From fd67309ba08fdcf3ddf07475daaed0af7a86f09e Mon Sep 17 00:00:00 2001 From: Philip Orr Date: Tue, 25 Apr 2023 10:34:09 +0000 Subject: [PATCH 14/19] Bug 28315: Remove duplicate function definition This patch removes the unnecessary second definition of the JS function PopupMARCFieldDoc from addbiblio.tt. To test: 1. Apply the patch 2. Check that addbiblio.tt contains only one function definition for PopupMARCFieldDoc 3. Navigate to "Cataloging" -> "Add MARC record" 4. Check that after clicking on the question mark symbol next to any MARC field, the loc description of that MARC field is opened in a new tab Signed-off-by: Lucas Gass Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi (cherry picked from commit a2b880e57bb1ccd4b8270ec8bfdcdc86e18a2e48) Signed-off-by: Matt Blenkinsop (cherry picked from commit 4a9be2cbe3da28bb73b1268f27d6ea0c7710f3fe) Signed-off-by: Lucas Gass (cherry picked from commit 2f31d13e94e98b890d990e26bcb81a106a8c3f0f) Signed-off-by: danyonsewell (cherry picked from commit 2f31d13e94e98b890d990e26bcb81a106a8c3f0f) --- .../prog/en/modules/cataloguing/addbiblio.tt | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index ca1f81a101..79b946f6da 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -451,20 +451,6 @@ function PopupMARCFieldDoc(field) { } } - function PopupMARCFieldDoc(field) { - [% IF Koha.Preference('marcfielddocurl') %] - var docurl = "[% Koha.Preference('marcfielddocurl').replace('"','"') | html %]"; - docurl = docurl.replace("{MARC}", "[% marcflavour | html %]"); - docurl = docurl.replace("{FIELD}", ""+field); - docurl = docurl.replace("{LANG}", "[% lang | html %]"); - window.open(docurl); - [% ELSIF ( marcflavour == 'MARC21' ) %] - _MARC21FieldDoc(field); - [% ELSIF ( marcflavour == 'UNIMARC' ) %] - _UNIMARCFieldDoc(field); - [% END %] - } - function _MARC21FieldDoc(field) { if(field == 0) { window.open("http://www.loc.gov/marc/bibliographic/bdleader.html"); From 0a2cb55c4a1e79b7cef4ae082932347afd1bc541 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 10 May 2023 10:41:30 +0200 Subject: [PATCH 15/19] Bug 33642: Fix 'No log found.' in viewlog It should ease translatability and remove an extra space. Signed-off-by: Owen Leonard Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 3ca450dbc97f12f895830e17562a2e118996a439) Signed-off-by: Matt Blenkinsop (cherry picked from commit 68412485e3eda514b4a5ca4c333dcae357978368) Signed-off-by: Lucas Gass (cherry picked from commit 13d068fc1a9877a92248647bbdd4079c27f141cf) Signed-off-by: danyonsewell (cherry picked from commit 13d068fc1a9877a92248647bbdd4079c27f141cf) --- .../intranet-tmpl/prog/en/modules/tools/viewlog.tt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt index 4285f92017..07de616b0d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -395,14 +395,13 @@ [% ELSE %]
      - No log found [% IF ( CATALOGUING ) %] - for Bibliographic record [% object | html %] + No log found for Bibliographic record [% object | html %]. + [% ELSIF ( MEMBERS ) %] + No log found for [% INCLUDE 'patron-title.inc' %]. + [% ELSE %] + No log found. [% END %] - [% IF ( MEMBERS ) %] - for [% INCLUDE 'patron-title.inc' %] - [% END %] - .
      [% END %] [% END %] From 234599857e55546638b2630ee7f35b3834aefba6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 10 May 2023 11:04:13 +0200 Subject: [PATCH 16/19] Bug 33677: Remove verbose option from koha-worker man Signed-off-by: Magnus Enger No more mention of verbose. Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 1bd49fcab8c03ee43aba12cae8661f9488c9bf8d) Signed-off-by: Matt Blenkinsop (cherry picked from commit 165c945b5eade8ddae60715781fc1a406b95e499) Signed-off-by: Lucas Gass (cherry picked from commit e31c60109ef48366637c9129d13289ab3d27a6a5) Signed-off-by: danyonsewell (cherry picked from commit e31c60109ef48366637c9129d13289ab3d27a6a5) --- debian/docs/koha-worker.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/debian/docs/koha-worker.xml b/debian/docs/koha-worker.xml index 3cb19e63cf..b7f5f039b6 100644 --- a/debian/docs/koha-worker.xml +++ b/debian/docs/koha-worker.xml @@ -59,10 +59,10 @@ - | - - Enable verbose output. - + + + Allows specifying the queue worker (defaults to 'default'). + | From 1e6cf232bf108cd4718127db69ee10e253c898ac Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 28 Apr 2023 14:30:19 -0400 Subject: [PATCH 17/19] Bug 32993: Holds priority changed incorrectly with dropdown selector Test Plan: 1) Find record with at least 3 holds. 2) Change first holds priority as 2, Priority is changed to 3. 3) Try to change priority back to 1, Priority is changed to 2. 4) Apply this patch 5) Reload the page 2) Change first holds priority as 2, Priority is changed to 2. 3) Try to change priority back to 1, Priority is changed to 1. Signed-off-by: David Nind Signed-off-by: Emmi Takkinen Signed-off-by: Hinemoea Viault Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 7d9e4cf41515234d8d61c369aab3c3e49be1ac3d) Signed-off-by: Matt Blenkinsop (cherry picked from commit c15e5068d0f13ed8a8b105ea1ed795030be6c269) Signed-off-by: Lucas Gass (cherry picked from commit 5d360af02cab6e89c56fca39d4091f2c3667582f) Signed-off-by: danyonsewell (cherry picked from commit 5d360af02cab6e89c56fca39d4091f2c3667582f) --- koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index c9d41cae35..8b89f5f06c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -1462,7 +1462,7 @@ var value = parseInt($(this).val()); var found_holds = $("select[name='rank-request'][disabled='disabled']").length ; //Count how many are found if( !isNaN(value) ) { //If moved to 'del' - var after = row.parent().find("tr:nth-child("+(value+1+found_holds )+")"); //Go to the row 1 after the new value (and skip found holds) + var after = row.parent().find(`tr:nth-child(${value+found_holds})`); //Go to the row 1 after the new value (and skip found holds) if (prev_rank_request > value) { row.insertBefore(after); } else { From e710ed7f0b1722fa9a6b6bc80765e91cbfdcb145 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 23 Jun 2023 11:52:28 +0100 Subject: [PATCH 18/19] Bug 30524: Unit tests Test plan: Run t/Output.t Run t/db_dependent/Auth.t Signed-off-by: Marcel de Rooy --- t/Output.t | 41 +++++++++++++++++++++++++++++++++++++++-- t/db_dependent/Auth.t | 1 + 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/t/Output.t b/t/Output.t index 02218deadd..55ca2dc436 100755 --- a/t/Output.t +++ b/t/Output.t @@ -17,16 +17,23 @@ use Modern::Perl; -use Test::More tests => 7; +use Test::More tests => 8; use Test::Warn; +use Test::MockModule; + +use File::Temp qw/tempfile/; use CGI qw ( -utf8 ); +use C4::Auth qw( get_template_and_user ); + use t::lib::Mocks; BEGIN { - use_ok('C4::Output', qw( output_html_with_http_headers parametrized_url )); + use_ok('C4::Output', qw( output_html_with_http_headers output_and_exit_if_error parametrized_url )); } +our $output_module = Test::MockModule->new('C4::Output'); + my $query = CGI->new(); my $cookie; my $output = 'foobarbaz'; @@ -93,3 +100,33 @@ subtest 'output_with_http_headers() tests' => sub { like($stdout, qr/Access-control-allow-origin: https:\/\/koha-community\.org/, 'Header set to https://koha-community.org'); close STDOUT; }; + +subtest 'output_and_exit_if_error() tests' => sub { + plan tests => 1; + + $output_module->mock( + 'output_and_exit', + sub { + my ( $query, $cookie, $template, $error ) = @_; + is( $error, 'wrong_csrf_token', 'Got right error message' ); + } + ); + + t::lib::Mocks::mock_config( 'pluginsdir', [ C4::Context::temporary_directory ] ); + my ( $fh, $fn ) = tempfile( SUFFIX => '.tt', UNLINK => 1, DIR => C4::Context::temporary_directory ); + print $fh qq|[% blocking_error %]|; + close $fh; + + my $query = CGI->new(); + $query->param('csrf_token',''); + my ( $template, $loggedinuser, $cookies ) = get_template_and_user( + { + template_name => $fn, + query => $query, + type => "intranet", + authnotrequired => 1, + } + ); + # Next call triggers test in the mocked sub + output_and_exit_if_error($query, $cookie, $template, { check => 'csrf_token' }); +}; diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t index 826aef82a6..0663cdc60a 100755 --- a/t/db_dependent/Auth.t +++ b/t/db_dependent/Auth.t @@ -388,6 +388,7 @@ subtest 'get_template_and_user' => sub { # Tests for the language URL paramete ); is($template->{VARS}->{'opac_name'}, "multibranch-19", "Opac name was set correctly"); is($template->{VARS}->{'opac_search_limit'}, "branch:multibranch-19", "Search limit was set correctly"); + ok(defined($template->{VARS}->{'csrf_token'}), "CSRF token returned"); delete $ENV{"HTTP_COOKIE"}; }; From e80f08ff393aab5daf10c33e4b3ddbe57993b7ed Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 13 Apr 2022 13:55:04 +0100 Subject: [PATCH 19/19] Bug 30524: [21.11] Core CSRF checking code Split out from bug 22990 as requested. Signed-off-by: David Cook Signed-off-by: Kyle M Hall Signed-off-by: Marcel de Rooy Bug 30524: Add xt/find-missing-csrf.t Signed-off-by: David Cook Signed-off-by: Kyle M Hall Signed-off-by: Marcel de Rooy Bug 30524: (QA follow-up) Polishing xt script Test plan: Run it again. Same results? Signed-off-by: Marcel de Rooy Bug 30524: Unit tests Test plan: Run t/Output.t Run t/db_dependent/Auth.t Signed-off-by: Marcel de Rooy --- C4/Auth.pm | 2 + C4/Output.pm | 33 ++++++-- .../prog/en/includes/csrf-token.inc | 1 + xt/find-missing-csrf.t | 82 +++++++++++++++++++ 4 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/csrf-token.inc create mode 100755 xt/find-missing-csrf.t diff --git a/C4/Auth.pm b/C4/Auth.pm index 13128407f5..26e994b66e 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -49,6 +49,7 @@ use C4::Auth_with_shibboleth qw( shib_ok get_login_shib login_shib_url logout_sh use Net::CIDR; use C4::Log qw( logaction ); use Koha::CookieManager; +use Koha::Token; # use utf8; @@ -299,6 +300,7 @@ sub get_template_and_user { $template->param( loggedinusernumber => $borrowernumber ); # FIXME Should be replaced with logged_in_user.borrowernumber $template->param( logged_in_user => $patron ); $template->param( sessionID => $sessionID ); + $template->param( csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $sessionID })); if ( $in->{'type'} eq 'opac' ) { require Koha::Virtualshelves; diff --git a/C4/Output.pm b/C4/Output.pm index 42c4011ca0..94bc8e0f95 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -34,6 +34,7 @@ use URI::Escape; use C4::Auth qw( get_template_and_user ); use C4::Context; use C4::Templates; +use Koha::Token; our (@ISA, @EXPORT_OK); @@ -314,9 +315,17 @@ sub is_ajax { To executed at the beginning of scripts to stop the script at this point if some errors are found. -Tests for module 'members': -* patron is not defined (we are looking for a patron that does no longer exist/never existed) -* The logged in user cannot see patron's infos (feature 'cannot_see_patron_infos') +A series of tests can be run for a given module, or a specific check. +Params "module" and "check" are mutually exclusive. + +Tests for modules: +* members: + - Patron is not defined (we are looking for a patron that does no longer exist/never existed) + - The logged in user cannot see patron's infos (feature 'cannot_see_patron_infos') + +Tests for specific check: +* csrf_token + will test if the csrf_token CGI param is valid Others will be added here depending on the needs (for instance biblio does not exist will be useful). @@ -332,16 +341,28 @@ sub output_and_exit_if_error { if ( not $current_patron ) { $error = 'unknown_patron'; } - elsif( not $logged_in_user->can_see_patron_infos( $current_patron ) ) { + elsif ( not $logged_in_user->can_see_patron_infos($current_patron) ) + { $error = 'cannot_see_patron_infos'; } - } elsif ( $params->{module} eq 'cataloguing' ) { + } + elsif ( $params->{module} eq 'cataloguing' ) { # We are testing the record to avoid additem to fetch the Koha::Biblio # But in the long term we will want to get a biblio in parameter $error = 'unknown_biblio' unless $params->{record}; } } - + elsif ( $params and exists $params->{check} ) { + if ( $params->{check} eq 'csrf_token' ) { + $error = 'wrong_csrf_token' + unless Koha::Token->new->check_csrf( + { + session_id => scalar $query->cookie('CGISESSID'), + token => scalar $query->param('csrf_token'), + } + ); + } + } output_and_exit( $query, $cookie, $template, $error ) if $error; return; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/csrf-token.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/csrf-token.inc new file mode 100644 index 0000000000..703d4eb036 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/csrf-token.inc @@ -0,0 +1 @@ + diff --git a/xt/find-missing-csrf.t b/xt/find-missing-csrf.t new file mode 100755 index 0000000000..15dd6ae626 --- /dev/null +++ b/xt/find-missing-csrf.t @@ -0,0 +1,82 @@ +#!/usr/bin/perl + +# Copyright 2021 Koha development team +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use Test::More tests => 1; +use File::Find; +use File::Slurp; +use Data::Dumper; + +my @themes; + +# OPAC themes +my $opac_dir = 'koha-tmpl/opac-tmpl'; +opendir ( my $dh, $opac_dir ) or die "can't opendir $opac_dir: $!"; +for my $theme ( grep { not /^\.|lib|js|xslt/ } readdir($dh) ) { + push @themes, "$opac_dir/$theme/en"; +} +close $dh; + +# STAFF themes +my $staff_dir = 'koha-tmpl/intranet-tmpl'; +opendir ( $dh, $staff_dir ) or die "can't opendir $staff_dir: $!"; +for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) { + push @themes, "$staff_dir/$theme/en"; +} +close $dh; + +my @files; +sub wanted { + my $name = $File::Find::name; + push @files, $name + if $name =~ m[\.(tt|inc)$] and -f $name; +} + +find({ wanted => \&wanted, no_chdir => 1 }, @themes ); + +my @errors; +for my $file ( @files ) { + my @e = check_csrf_in_forms($file); + push @errors, { file => $file, errors => \@e } if @e; +} + +is( @errors, 0, "Template variables should be correctly escaped" ) + or diag(Dumper @errors); + +sub check_csrf_in_forms { + my ( $file ) = @_; + + my @lines = read_file($file); + my @errors; + return @errors unless grep { $_ =~ m| starting on line $open is missing it's corresponding csrf_token include (see bug 22990)" + if !$found; + $found = 0; + } + } + return @errors; +}