koha.git
6 years agoBug 18276: Remove GetBiblioFromItemNumber - Course reserves
Jonathan Druart [Wed, 15 Mar 2017 13:15:30 +0000 (10:15 -0300)]
Bug 18276: Remove GetBiblioFromItemNumber - Course reserves

Values from the items, biblio and biblioitems tables are used in the template,
so we need to pass all of them to the template, but separately.
That way we easily see which field from which table we are displaying.

Test plan:
Create a course reserve and add items.
Correct information must be displayed on the detail page of the course
reserve, on staff and OPAC interface.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 17680: Remove Koha::Upload use incorrectly added
Tomas Cohen Arazi [Fri, 7 Jul 2017 19:53:09 +0000 (16:53 -0300)]
Bug 17680: Remove Koha::Upload use incorrectly added

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 17680: Fix conflict with bug 18651
Jonathan Druart [Wed, 5 Jul 2017 20:11:24 +0000 (17:11 -0300)]
Bug 17680: Fix conflict with bug 18651

$issue is now a Koha::Checkout, not a hashref

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 17680: Add few tests for AddReturn when overdue
Jonathan Druart [Thu, 15 Jun 2017 15:18:49 +0000 (12:18 -0300)]
Bug 17680: Add few tests for AddReturn when overdue

To make sure the last patch fixes the issue

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 17680: Fix regression - is_overdue must be called
Jonathan Druart [Wed, 14 Jun 2017 13:48:29 +0000 (10:48 -0300)]
Bug 17680: Fix regression - is_overdue must be called

is_overdue must be called even if there is not dropbox date (!)

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 17680: C4::Circulation - Remove GetItemIssue, complex calls
Jonathan Druart [Fri, 25 Nov 2016 12:53:03 +0000 (13:53 +0100)]
Bug 17680: C4::Circulation - Remove GetItemIssue, complex calls

There are a few calls to GetItemIssue where it's not as easy to make
sure everything will be fine just replacing the calls with a
Koha::Issues->find
- In AddReturn the overdue flag is used (that's why this patch depends
on bug 17689)
- In CanBookBeRenewed, as well as the overdue flag the dates converted
to DateTime were used. It's now our job to convert them when we need
them.
- Same in AddRenewal but we also call _CalculateAndUpdateFine, so we
need to update the variables in this subroutine.

Note that, prior to this patch, AddReturn returned the GetItemIssue
hashref in the $iteminformation. Most of the time this variable is not
used, I have found only 1 place where it's used: circ/returns.pl
TODO: In this script we should call ->is_overdue instead of the
DateTime->compare calls

Test plan:
All the circulation tests must pass (it's how I have caught the specific
cases).
Do some checkins/checkouts/renewal and focus on the due date

Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 17680: C4::Circulation - Remove GetItemIssue
Jonathan Druart [Fri, 25 Nov 2016 13:00:34 +0000 (14:00 +0100)]
Bug 17680: C4::Circulation - Remove GetItemIssue

This patch simply removes the C4::Circulation::GetItemIssue subroutine

Test plan:
At this point, `git grep GetItemIssue` should not return any occurrence
in the codebase

Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 17680: C4::Circulation - Remove GetItemIssue, simple calls
Jonathan Druart [Fri, 25 Nov 2016 12:02:01 +0000 (12:02 +0000)]
Bug 17680: C4::Circulation - Remove GetItemIssue, simple calls

C4::Circulation::GetItemIssue returned all the issue and item
informations for a given issue. Moveover it also did some date
manipulations. Most of the time this subroutine was called, there
additional information were useless as the caller usually just needed
the basic issue's infos 'from the issue table).

This first patch updates the simple calls, ie. the ones that just need
the issue's infomations.

Test plan:
The following operations should success:
- transfer a book
- create a rule for on-site checkouts and confirm that a patron cannot
check more items out that it's defined in the rule.
- Renew an issue using ILSDI
- Using SIP confirm that you are able to see your issues

Followed test plan, works as expected
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18104: [QA Follow-up] Add a test for customized name in AE
Marcel de Rooy [Fri, 23 Jun 2017 08:12:44 +0000 (10:12 +0200)]
Bug 18104: [QA Follow-up] Add a test for customized name in AE

Test plan:
Run t/db_dependent/SIP/Message.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18104 - allow SIP2 field AE (personal name ) to be customized
Kyle M Hall [Mon, 6 Mar 2017 12:05:31 +0000 (12:05 +0000)]
Bug 18104 - allow SIP2 field AE (personal name ) to be customized

Koha's SIP2 server sends the patron's name in the format "Firstname
Surname" which is not very good for machine reading. We need to allow
the format of the patron name to be customized in a manner similar to
what is done with the DA field on bug 16755.

Test Plan:
1) Apply this patch, start or restart your SIP server
2) Find a patron with a first and last name
3) Send a patron information request via the sip2 cli tool
4) Note the AE field has the format "<firstname> <surname>" ( i.e. the current behavior )
5) Add this parameter to the login stanza you are using:
   ae_field_template="[% patron.surname %][% IF patron.firstname %], [% patron.firstname %][% END %]"
6) Restart your SIP server
7) Repeat step 3
8) Note the AE field now has the format "<surname>, <firstname>"

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Benjamin Daeuber <BDaeuber@cityoffargo.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 16755 - allow SIP2 field DA ( hold patron name ) to be customized
Kyle M Hall [Thu, 29 Dec 2016 14:22:04 +0000 (14:22 +0000)]
Bug 16755 - allow SIP2 field DA ( hold patron name ) to be customized

The SIP2 DA field that Koha transmits is an odd and arbitrary format
that some SIP2 clients cannot handle. It would be best if this
format were customizable on a per-login basis in the same manner as
the AV field.

Test Plan:
1) Find an item that is checked out with holds
2) Return the item via SIP2 ( using the SIP2 cli emulator )
3) Note the value of the DA field
4) Apply this patch, restart your SIP2 server
5) Repeat step 2
6) Note the DA field value has not changed
7) Add this parameter to the login stanza you are using:
   da_field_template="[% patron.surname %][% IF patron.firstname %], [% patron.firstname %][% END %]"
8) Restart the SIP2 server again
9) Repeat step 2
10) Note the DA field returned is now in the format "$surname, $firstname"

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Benjamin Daeuber <BDaeuber@cityoffargo.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18465: (followup) Fix issue with patron lists an do not use clone
Marc Véron [Fri, 23 Jun 2017 16:48:00 +0000 (18:48 +0200)]
Bug 18465: (followup) Fix issue with patron lists an do not use clone

This followup fixes duplex printing with patron lists.

Additionaly, it uses simple copy instead of clone and removes a
superfluous line, see comments #15 - #17

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18465 - Patron card creator: Print on duplex card printer
Marc Véron [Thu, 20 Apr 2017 18:43:11 +0000 (20:43 +0200)]
Bug 18465 - Patron card creator: Print on duplex card printer

Card printers with duplex functionality need as input a PDF file where odd pages contain
the front side and even pages the back side of the cards.

This patch adds such functionality.

To prepare test:
- In Patron card creator > Templates, prepare a 1 up template (1 column / 1 row) that
  fits to a single card. Give it a name like 'Duplex card template'
  (Attention, Card with and Card height seem to have wrong labels, that will go
  to a separate bug).
- In Patron card creator > Layouts create a layout for the front side and one for
  the back side. Give them names to easily remember (Card front layout, Card back layout)
- Go to Patron card creator > Batches and test both layouts together with the
  1 up template. Save and keepp both test files as reference.

To test:
- Apply patch. Restart memcached and plack.
- Go to Patron card creator > Batches
- Click "Export" for a batch
- In the following screen, note the new field "Select a layout for the back side"
  with a hint what it is used for
- Leave it on 'Back side layout not used', export and compare output with test ooutput
  from preparation. It should be the same
- Select the layout you prepared for the back side.
- Export - this file should contain 2 PDF pages per patron, one first with the
  front side, second with the back side.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18616 - The "Add forgot password link to OPAC" should allow patrons to use their...
David Kuhn [Tue, 6 Jun 2017 16:38:07 +0000 (09:38 -0700)]
Bug 18616 - The "Add forgot password link to OPAC" should allow patrons to use their library card number in addition to username

Allow patrons to enter either their library card number or user name in the "Log in" box for password recovery.

Most patrons at our library use their card number to log in and are unaware of what their userid is. However there are some who have set a

customized userid and would prefer to use that. This patch would allow either to be entered for password recovery.

To test:
1. Enable the password recovery feature.
2. In the OPAC, click on "Forgot you password?" link and enter a valid library card number.
3. The error message "No account found with the provided information" appears.
4. Apply the patch.
5. Repeat step 2. The recovery email is now sent.

Note: Moved patch from 16711 back here and re-tested.
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 16711: OPAC Password recovery: Handling if multiple accounts have the same mail...
Marc Véron [Sun, 21 May 2017 16:28:48 +0000 (18:28 +0200)]
Bug 16711: OPAC Password recovery: Handling if multiple accounts have the same mail address

To reproduce:
- Create 3 Accounts, login names are test01, test02, test03, Email is the same
for all.
- Go to OPAC -> Password recovery and indicate E-Mail only
- You will get an email for only one of the accounts above.

To test:
- Apply patch, restart memcached and plack
- Go to db, delete from borrower_password_recovery;
- Try steps above to reproduce. You will get an error message:
    Account identification with this email address only is ambiguous.
    Please use the field 'Login' as well.
- Verify that other cases work as before (provide valid / invalid login only,
  provide valid email for an existing account, provide unknown email, provide
  both login and email with all combinations of valid / invalid)

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Bug 16711: (QA-followup) Use count directly

See comment # 13

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18848: borrowers.lastseen comment typo
Lee Jamison [Thu, 22 Jun 2017 16:42:15 +0000 (16:42 +0000)]
Bug 18848: borrowers.lastseen comment typo

Typo in comment for the lastseen column in the borrowers table.

To test:
1. Verify lastseen column displays "last time a patron has been seed"
2. Apply patch
3. Verify lastseen column changed to "last time a patron has been seen"

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18830: Fix phrasing of screen message
Colin Campbell [Tue, 20 Jun 2017 15:35:35 +0000 (16:35 +0100)]
Bug 18830: Fix phrasing of screen message

Verb should be plural in this message

Signed-off-by: Israelex A Veleña for KohaCon17 <israelex19@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18824: Remove stray i from matching-rules.tt
Marc Véron [Mon, 19 Jun 2017 19:23:54 +0000 (21:23 +0200)]
Bug 18824: Remove stray i from matching-rules.tt

The file
koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt
contains a stray i that should not be there.
This patch removes it.

Signed-off-by: Chris Kirby <chris.kirby@ilsleypubliclibrary.org>
Applied patch.
Checked line 516. Stray i had been removed.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18848: borrowers.lastseen comment typo
Lee Jamison [Thu, 22 Jun 2017 16:42:15 +0000 (16:42 +0000)]
Bug 18848: borrowers.lastseen comment typo

Typo in comment for the lastseen column in the borrowers table.

To test:
1. Verify lastseen column displays "last time a patron has been seed"
2. Apply patch
3. Verify lastseen column changed to "last time a patron has been seen"

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18881: [QA Follow-up] Remove even more
Marcel de Rooy [Mon, 3 Jul 2017 07:31:52 +0000 (09:31 +0200)]
Bug 18881: [QA Follow-up] Remove even more

Removing the commented section from the template: If it does not work, it should not be here.
When it works again, put it back in.

Since @itemtypesloop is not used, remove it from the script too.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18881: Remove dead code from view_holdsqueue.pl
Marc Véron [Fri, 30 Jun 2017 18:20:44 +0000 (20:20 +0200)]
Bug 18881: Remove dead code from view_holdsqueue.pl

Aleisha spotted the typo in $itemtypes and proposed a correction on bug 18859.
The description was not even used. Template calls GetDescription.

To test:
Verify that viewing the holds queue still works as expected.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 14572 - insert_single_holiday() forces a value on an AUTO_INCREMENT column, durin...
Rodrigo Santellan [Wed, 21 Jun 2017 18:40:43 +0000 (15:40 -0300)]
Bug 14572 - insert_single_holiday() forces a value on an AUTO_INCREMENT column, during an INSERT

Removing all the id from the columns on the inserts and removing the
parameter '' of the values for the id.

Test plan:
1) Go to tools -> calendar
2) Add a Holiday only on this day.
3) Add a Holiday repeated every same day of the week.
4) Add a Holiday repeated yearly on the same date.
5) Add a Holidays on a range.
6) Add a Holidays repeated yearly on a range.
7) You should have the five calendars displayed.

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18755: Allow empty passwords in Patron Info to return OK
Colin Campbell [Thu, 8 Jun 2017 11:59:55 +0000 (12:59 +0100)]
Bug 18755: Allow empty passwords in Patron Info to return OK

With this patch a parameter 'allow_empty_passwords="1" can be added to a
login in the SIP configuration file to allow the behaviour as was normal
before the patch for bug 16610 was applied. Some sip clients rely on
this behaviour sending an empty password field when they wish to
validate to user but do not have the password.
If a password is supplied it will be validated

A test has been added to Message.t to confirm this behaviour

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18771: CGI.pm: Subroutine multi_param redefined
Mark Tompsett [Fri, 9 Jun 2017 17:01:14 +0000 (13:01 -0400)]
Bug 18771: CGI.pm: Subroutine multi_param redefined

The commands in the test plan are examples, and may need varying
depending on your installation. This was created as a result
of attempting to clean the installation process up. However,
I believe the redefine might exist normally too. I just didn't
check. This is tested on a Debian 8 box sudo apt-get update'd
fully.

TEST PLAN
---------
empty error log
$ echo > ~/koha-dev/var/log/koha-error_log

drop and recreate and empty db
> drop database koha_library;
> create database koha_library;
> quit

run the web installer, but DO NOT LOG IN!
*opening chrome to Staff Client URL*

check the error log
$ less ~/koha-dev/var/log/koha-error_log
...
[Fri Jun 09 13:08:52.793627 2017] [cgi:error] [pid 5802] [client 192.168.71.101:58169] AH01215: [Fri Jun  9 13:08:52 2017] CGI.pm: Subroutine multi_param redefined at /usr/share/perl5/CGI.pm line 419.
...

apply patch

empty error log
$ echo > ~/koha-dev/var/log/koha-error_log

refresh the installation login page

recheck the error log
$ less ~/koha-dev/var/log/koha-error_log

notice no reference to "Subroutine multi_param redefined"

run koha qa test tools

Notice that it is just a require CGI; and comment added.

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18634: Handle colliding translation for preference sections
Marcel de Rooy [Wed, 14 Jun 2017 13:37:55 +0000 (15:37 +0200)]
Bug 18634: Handle colliding translation for preference sections

Problem on this report was caused by translating the tabs Privacy
and Payments by the same string. This caused overwriting a hash entry.

This patch tests if the key already exists and if so, it merges the
entries instead of overwriting the old contents.

Test plan:
[1] Make sure that e.g. Privacy and Payments translate to e.g Vie privee.
[2] Run translate install fr-CA (or the language you altered)
[3] Without this patch you should loose preferences from either Privacy or
    Payments. With this patch, they should be merged.

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

Signed-off-by: Blou <philippe.blouin@inlibro.com>
Reset the .po files, reproduced the problem.  Applied the patch and suddenly 'paypal' appeared.

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18801: DBRev 17.05.00.003
Jonathan Druart [Thu, 6 Jul 2017 17:28:18 +0000 (14:28 -0300)]
Bug 18801: DBRev 17.05.00.003

6 years agoBug 18801: [Follow-up] Dbrev to repair bad auth type codes
Marcel de Rooy [Thu, 15 Jun 2017 13:47:21 +0000 (15:47 +0200)]
Bug 18801: [Follow-up] Dbrev to repair bad auth type codes

Test plan
Run updatedatabase.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18801 - Merging authorities has an invalid 'Default' type in the merge framework...
Nick Clemens [Wed, 14 Jun 2017 13:19:10 +0000 (09:19 -0400)]
Bug 18801 - Merging authorities has an invalid 'Default' type in the merge framework selector

To test:
1 - Find two authorities and start a merge
2 - Leave the dropdown at 'Default'
3 - Merge records and note you get an error and can no longer view the
new record
4 - Check DB value of record authtypecode = 'Default'
5 - Apply patch
6 - Find two other authorities
7 - Merge leaving selector at default
8 - Success
9 - Check DB value of record authtypecode = ''

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18434 - Followup fix tests for sorting and factes
Nick Clemens [Mon, 3 Jul 2017 09:42:21 +0000 (09:42 +0000)]
Bug 18434 - Followup fix tests for sorting and factes

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18434 - Followup - same changes for sort and facet fields
Nick Clemens [Fri, 16 Jun 2017 14:01:12 +0000 (10:01 -0400)]
Bug 18434 - Followup - same changes for sort and facet fields

To test:
1 - Index some stuff with multiple fields defined for sorting
  i.e. Authorites - make heading sortable - default is 110a and 111a for
  heading - a record with 111a empty will make the sort field empty
2 - view the record:
curl http://localhost:9200/koha_kohadev_authorities/data/30?pretty=true
3 - Note the blank field
4 - Apply patch
5 - Reindex
6 - Fields should be correctly populated

Unit tests to follow (once I have the originals working for all)

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18434: (QA followup) Move _convert_marc_to_json tests into Indexer.t
Tomas Cohen Arazi [Mon, 15 May 2017 14:46:00 +0000 (11:46 -0300)]
Bug 18434: (QA followup) Move _convert_marc_to_json tests into Indexer.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18434: Elasticsearch indexing broken with newer catmandu version
Nick Clemens [Fri, 14 Apr 2017 14:03:11 +0000 (10:03 -0400)]
Bug 18434: Elasticsearch indexing broken with newer catmandu version

To test:
1 - Make sure you have latest koha deps, catmandu versions should be:
    libcatmandu-marc-perl   1.09-1~kohadev1
    libcatmandu-perl        1.0304-2~kohadev1
2 - Reindex elastic
3 - Try searching and likely notice odd results
4 - Try:
curl -XGET
'http://localhost:9200/koha_kohadev_biblios/data/792?pretty=true'
with a known biblionumber and notice some null fields
5 - Apply patch
6 - Reindex
7 - Note fields are populated and search works as expected

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18434: Add tests for K:SE:E::get_fixer_rules
Tomas Cohen Arazi [Fri, 12 May 2017 18:39:25 +0000 (15:39 -0300)]
Bug 18434: Add tests for K:SE:E::get_fixer_rules

This patch tries to introduce exhaustive tests for this class method.
I didn't try to provide a regression test for the current bug per-se, but
cover the current method behaviour as much as I could.

(kidclamp) I added a quick test of _convert_marc_to_json to use the mocking here
and illuminate what the change does, before the patches this should
fail (fields are indexed in place of one another), after it should succeed (new indexed fields are appended).

A minor bug is highlighted by this new tests, I'll provide a followup for it.

To test:
- Run:
  $ sudo koha-shell kohadev
 k$ de kohaclone
 k$ prove t/db_dependent/Koha_Elasticsearch.t
=> FAIL: The returned fixer rules are not the expected ones

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18756 - add Unit Test
Fridolin Somers [Wed, 14 Jun 2017 10:33:25 +0000 (12:33 +0200)]
Bug 18756 - add Unit Test

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18756: Users can view aq.baskets even if they are not allowed
Christophe Croullebois [Thu, 8 Jun 2017 13:17:56 +0000 (13:17 +0000)]
Bug 18756: Users can view aq.baskets even if they are not allowed

Due to bad use of grep syntax if there is one or more Basket Users the result of grep is not equal to 0 and the borrower is allowed.

Test plan :
1- select system preference 'AcqViewBaskets' on 'user'
2- create 2 borrowers (A, B) with only permissions on acquisition :
group_manage
order_manage
order_receive
staff
3- login with A and create a basket
4- add a basquet manager other than B
5- relog with account B
6- you can see the basket

Apply the patch.
The basket is no longer visible.
1- relog with A
2- add basquet manager B
3- relog with B
5- you must see the basket

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18870: Force scalar context for Koha::Club methods
Jonathan Druart [Wed, 5 Jul 2017 23:03:24 +0000 (20:03 -0300)]
Bug 18870: Force scalar context for Koha::Club methods

These 2 methods are called from the template in list context.
However since bug 18539 Koha::Objects->find can no longer be called in
list context.
Forcing the context to scalar fixes the problem and should not
introduced side-effects.

Test plan:
- Create a club template
- Create a club using this template
=> Without this patch you should no longer get the following error:
Template process failed: undef error - Cannot use "->find" in list
context at /home/vagrant/kohaclone/Koha/Club.pm line 51.

Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18228: DBRev 17.05.00.002
Jonathan Druart [Thu, 6 Jul 2017 16:58:05 +0000 (13:58 -0300)]
Bug 18228: DBRev 17.05.00.002

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 17554: (followup) Shibboleth check should use ->find too
Tomas Cohen Arazi [Mon, 26 Jun 2017 18:25:19 +0000 (15:25 -0300)]
Bug 17554: (followup) Shibboleth check should use ->find too

There was a remaining use of C4::Members::GetBorrowersWithEmail in Auth.pm.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
6 years agoBug 17554: Koha::Patrons - Remove GetBorrowersWithEmail
Jonathan Druart [Fri, 4 Nov 2016 14:43:21 +0000 (14:43 +0000)]
Bug 17554: Koha::Patrons - Remove GetBorrowersWithEmail

C4::Members::GetBorrowersWithEmail can be easily replaced with
Koha::Patrons->search({ email => $email });

Test plan:
Confirm that you are still able to use PKI authentication

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
6 years agoBug 17738: [QA Follow-up] Remove second find of same patron
Marcel de Rooy [Fri, 30 Jun 2017 10:02:00 +0000 (12:02 +0200)]
Bug 17738: [QA Follow-up] Remove second find of same patron

We can just use the $patron from line 77 here.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 17738: Remove warning about redeclaration of $patron
Jonathan Druart [Mon, 17 Apr 2017 12:00:33 +0000 (09:00 -0300)]
Bug 17738: Remove warning about redeclaration of $patron

Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 17738: Remove C4::Reserves::GetReservesFromBorrowernumber
Jonathan Druart [Wed, 7 Dec 2016 13:43:43 +0000 (14:43 +0100)]
Bug 17738: Remove C4::Reserves::GetReservesFromBorrowernumber

At this point, there should not be any occurrences of
GetReservesFromBorrowernumber anymore.

Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 17738: Replace GetReservesFromBorrowernumber with Koha::Patron->get_holds
Jonathan Druart [Wed, 7 Dec 2016 13:42:48 +0000 (14:42 +0100)]
Bug 17738: Replace GetReservesFromBorrowernumber with Koha::Patron->get_holds

This patch replace the different calls to GetReservesFromBorrowernumber
with a calls to Koha::Patron->get_holds.
In some places we need to get a restricted set of holds, that's why we
process a search on this holds returned by ->get_holds (on the found
status for instance).

The changes are quite trivial and reading the diff should be enough to
catch bugs.

Test plan:
I would suggest to test this patch with patches from bug 17736 and bug 17737,
to place different kind of holds (biblio and item level, future and
past).
Then do a whole workflow to detect bug, view a record, delete record,
order, place a hold on an item which has been ordered, etc.
The hold's informations should always be the same without or without
these patches.

Tested both patches together, works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 17843: [QA Follow-up] Some polishing
Marcel de Rooy [Fri, 23 Jun 2017 08:43:16 +0000 (10:43 +0200)]
Bug 17843: [QA Follow-up] Some polishing

Resolve warning from members/summary-print.pl:
    "my" variable $itemtype masks earlier declaration in same scope

Test if find returns a Koha object in GetDescription.
Test if find returns a Koha object too in shelves.pl. While testing, I had
a crash on a biblioitem with itemtype NULL (bad record, but these things
tend to happen somehow.)
Can't call method "imageurl" on an undefined value at virtualshelves/shelves.pl line 253.
Same for opac/opac-shelves.pl.

Note: Did not add tests everywhere but generally, I have the impression that
we do not sufficiently test on the results of Koha::Object->find. Mostly we
just assume that it will find a record. Several reports include fixes to
resolve that wrong assumption.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 17843: Remove C4::Koha::getitemtypeinfo
Jonathan Druart [Wed, 4 Jan 2017 09:32:26 +0000 (10:32 +0100)]
Bug 17843: Remove C4::Koha::getitemtypeinfo

At this point there should not be any calls to this subroutine.

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 17843: Replace C4::Koha::getitemtypeinfo with Koha::ItemTypes
Jonathan Druart [Wed, 4 Jan 2017 09:30:47 +0000 (10:30 +0100)]
Bug 17843: Replace C4::Koha::getitemtypeinfo with Koha::ItemTypes

The C4::Koha::getitemtypeinfo subroutine did the almost same job as
GetItemTypes. On top of that it returned the imageurl value processed by
C4::Koha::getitemtypeimagelocation.
This value is only used from the 2 [opac-]shelves.pl scripts. Then it's
better not retrieve it only when we need it.

Test plan:
Play with the different scripts touched by this patch and focus on item
types. The same description as prior to this patch must be displayed.
Note that sometimes it is not the translated description which is
displayed, but that should be fixed on another bug report. Indeed we do
not expect this patch to change any behaviors.

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18782: Remove unused C4::Serials::getsupplierbyserialid
Julian Maurice [Mon, 12 Jun 2017 10:28:31 +0000 (12:28 +0200)]
Bug 18782: Remove unused C4::Serials::getsupplierbyserialid

TEST PLAN
----------
git grep -i getsupplierby
-- only the code removed and the test tweaked
git bz apply 18782
sudo koha-shell -c bash kohadev
prove -v t/db_dependent/Serials.t
qa -v 2 c 1
exit
-- sign off

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18228: QA Followup - use gender neutral language in new tests
Nick Clemens [Mon, 3 Jul 2017 17:01:02 +0000 (17:01 +0000)]
Bug 18228: QA Followup - use gender neutral language in new tests

6 years agoBug 18228: Add missing comma in kohastructure.sql
Jonathan Druart [Mon, 15 May 2017 13:44:47 +0000 (10:44 -0300)]
Bug 18228: Add missing comma in kohastructure.sql

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
6 years agoBug 18228: Adjust Virtualshelves.t
Marcel de Rooy [Wed, 8 Mar 2017 15:28:59 +0000 (16:28 +0100)]
Bug 18228: Adjust Virtualshelves.t

Test plan:
Run t/db_dependent/Virtualshelves.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Eric Gosselin <eric.gosselin@inlibro.com>
Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
6 years agoBug 18228: Implement the new columns in code
Marcel de Rooy [Wed, 8 Mar 2017 14:31:25 +0000 (15:31 +0100)]
Bug 18228: Implement the new columns in code

The two new columns as mentioned in the commit message of the table
revision must be used in the codebase now.

Highlighting some changes in Koha::VirtualShel[f|ves]:
[1] Additional methods is_public and is_private.
[2] Method add_biblio did not check permissions. Does now. No impact on the
    interface, but one call in the unit test was affected.
[3] Method remove_biblios is signficantly simplified. Removed a FIXME.
[4] Method can_biblios_be_removed now redirects to can_biblios_be_added.
    A followup report may deal with unifying those routines.
[5] Condition in get_some_shelves changed.
[6] The reference to allow_add in get_shelves_containing_record can simply
    be removed.

opac-shelves.pl and shelves.pl now pass the default setting of Owner only
to the template.
Templates shelves.tt and opac-shelves.tt now include the new permission
field with three choices as mentioned in the table revision patch.

opac-addbybiblionumber.pl and addbybiblionumber now need a check on
allow_change_from_owner; search conditions slightly adjusted to the new
permission scheme.

Test plan:
When we refer to visibility in the test plan, please check the Add to-combo
on opac search results and staff results. And check opac-addbybiblionumber
by clicking Save to Lists from opac results.
The step 'Check delete' means: open the list in opac and check if you see
the Delete button below the entries (only check, do not delete).

[ 1] Create private list I01 (perm=Owner)
[ 2] Check visibility: Seen.
[ 3] Add a book. (Change by owner should be allowed.)
[ 4] Check delete: Yes.
[ 5] Edit list I01, set perm=Nobody
[ 6] Check visibility: Not seen.
[ 7] Check delete: No.
[ 8] Share list I01 with another patron.
[ 9] Check visibility for the other patron: Not seen.
[10] Check delete for the other patron: No.
[11] Change permission of list I01 to Anyone (by owner).
[12] Check visibility for the other patron: Seen.
[13] Let other patron add a book (change is allowed).
[14] Let owner delete the same book again (change allowed).

[15] Create public list U01 (perm=Owner)
[16] Check visibility: Seen.
[17] Add a book. (Change by owner should be allowed.)
[18] Login as other user. Check visibility: Not seen. Check delete: No.
[19] Change permission of U01 to Nobody (by owner)
[20] As owner: Check visibility: Not seen. Check delete: No.
[21] As other user: Check visibility: Not seen. Check delete: No.
[22] Create public list U02 (perm=Anyone)
[23] Add a book by owner.
[24] Delete the same book by other user. Add another book.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
6 years agoBug 18228: DBIx schema changes for Virtualshelve.pm
Marcel de Rooy [Wed, 8 Mar 2017 13:19:34 +0000 (14:19 +0100)]
Bug 18228: DBIx schema changes for Virtualshelve.pm

No test plan.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
6 years agoBug 18228: Table revision of virtualshelves
Marcel de Rooy [Wed, 8 Mar 2017 13:10:32 +0000 (14:10 +0100)]
Bug 18228: Table revision of virtualshelves

In order to make the permissions easier, we will replace the columns
allow_add, allow_delete_own and allow_delete_other by two new columns
allow_change_from_owner and allow_change_from_others.

The distinction between adding or deleting an entry is no longer made.
If you have change permission, you can do both. Also deleting an entry
does no longer depend on who added the entry.
Formerly, the owner could always add entries. It is now possible to
make a list readonly.

We will not use the combination of owner=no and other=yes. This will
leave us three possibilities:
[1] owner=no, other=no: The list is read-only. No one can change
    contents of the list. Naturally, the owner can edit permissions.
[2] owner=yes, other=no: Only the owner can change contents.
[3] owner=yes, other=yes: Anyone seeing the list can change contents.
    This especially applies to shared lists and public lists.

The two database columns will be presented in the interface as one
permission field offering the three abovementioned options.

Test plan:
[1] Run the db rev.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
6 years agoBug 18214: Add check for shared or public list
Marcel de Rooy [Thu, 22 Jun 2017 06:55:16 +0000 (08:55 +0200)]
Bug 18214: Add check for shared or public list

Following the idea behind bug 10865, we are only showing the permissions
when the list is shared or public.
Adding a simple test in opac-shelves here.

Note 1: Since the owner can always add or delete entries, the permissions
will not be relevant anymore for a strictly private list.

Note 2: Staff view always shows the permissions. This could have been
changed here too, but that change is far less urgent (bug 10865 did not
touch staff view and bug 18228 will rearrange permissions anyway).

Test plan:
[1] Verify on OPAC that you see the permissions for a private list with
    shares or a public list. And you do not see them for a private list
    without shares.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18214: Cannot edit list permissions of a private list
Marcel de Rooy [Mon, 6 Mar 2017 08:44:48 +0000 (09:44 +0100)]
Bug 18214: Cannot edit list permissions of a private list

If you have disabled the pref OpacAllowPublicListCreation, your users are
not able to edit the list permissions for private/shared lists.
For a private list they may only be theoretically relevant, but for a shared
list they are relevant.
Since we do not always know the history of a list (has it been public or
shared, does it contains entries from other users) and therefore permissions
are even relevant for a currently private list, we should just allow editing
these permissions.

Test plan:
[1] Do not yet apply this patch.
[2] Disable OpacAllowPublicListCreation.
[3] Create a private list in OPAC. Edit the list. Verify that you do not
    see the permission combo boxes.
[4] Apply this patch. Edit the list again. Do they appear now?

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Magnus Enger <magnus@libriotech.no>
Works as advertised.

6 years agoBug 18651: Do no LOCK/UNLOCK the table
Jonathan Druart [Wed, 21 Jun 2017 17:14:09 +0000 (14:14 -0300)]
Bug 18651: Do no LOCK/UNLOCK the table

We cannot LOCK the old_issues table here, other tables are accessed and DBIx::Class rename it with "me":
DBD::mysql::st execute failed: Table 'me' was not locked with LOCK
TABLES [for Statement "SELECT `me`.`issue_id`, `me`.`borrowernumber`,
`me`.`itemnumber`, `me`.`date_due`, `me`.`branchcode`,
`me`.`returndate`, `me`.`lastreneweddate`, `me`.`renewals`,
`me`.`auto_renew`, `me`.`auto_renew_error`, `me`.`timestamp`,
`me`.`issuedate`, `me`.`onsite_checkout`, `me`.`note`, `me`.`notedate`
FROM `old_issues` `me` WHERE ( `me`.`issue_id` = ? )" with ParamValues:
0='2'] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1832.

Consequence: We could have a checkin refused if there is a race, but
this is the simplest and safest way to fix it.

6 years agoUpdate mailmap - Jonathan Druart
Jonathan Druart [Wed, 21 Jun 2017 15:41:22 +0000 (12:41 -0300)]
Update mailmap - Jonathan Druart

I do not longer work at biblibre

6 years agoBug 18800: Patron card images: Add some more explanation to upload page and fix small...
Marc Véron [Wed, 14 Jun 2017 09:10:56 +0000 (11:10 +0200)]
Bug 18800: Patron card images: Add some more explanation to upload page and fix small translatabiity issue

The file
koha-tmpl/intranet-tmpl/prog/en/modules/help/patroncards/image-manage.tt
has a small translatability issue (sentence splitting by html tags).

This patch fixes it and adds a little bit more explanation about
uploading, using and replacing such images.

To test:
- Verify that text changes make sense
- Apply patch
- Go to Home > Tools > Patron card creator > Images and verify
  that the page displays properly

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18684 - Get rid of %%] in translation for currency.tt
Marc Véron [Fri, 26 May 2017 19:08:27 +0000 (21:08 +0200)]
Bug 18684 - Get rid of %%] in translation for currency.tt

File add koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt exposes
parts of template directives due to html tags inide directives. Fix it using
the HtmlTags filter.

To verify:
- Create a translation for a language 'aa-AA
- po file aa-AA-staff-prog.po / translate.koha-community.org for 17.05 contains a line
  '%%]'%sCurrencies %s
To test:
- Apply patch on top of Bug 18665
- Recreate translation
- Verify that line above is gone
- Verify that in staff client currencies administration wors as before

Followed test plan and it worked as intended
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
Bug 18684: (followup) Move 2 closing h3 tags to end of previous lines

See comment #4

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18665: Add test for HtmlTags.pm
Marc Véron [Thu, 25 May 2017 19:52:09 +0000 (21:52 +0200)]
Bug 18665: Add test for HtmlTags.pm

This patch adds tests for the tt filter HtmlTags.pm

To test: prove -v t/HtmlTags.t should pass

Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18665 - Translatability: Add tt filter to allow html tags inside tt directives
Marc Véron [Wed, 24 May 2017 14:06:31 +0000 (16:06 +0200)]
Bug 18665 - Translatability: Add tt filter to allow html tags inside tt directives

HTML tags inside template toolkit directives are not allowed because of translation issues.
Add a filter that handles HTML tags.

Note you need to write quotes ' around the text you want displayed as a
heading

To test:
- Apply patch
- Add [% USE HtmlTags %] to the top of a tt file
- Add something like [% 'My nice title' | $HtmlTags tag="h1" %] to the tt file
- Verify that in output 'My nice title' has h1 tags
- Change template directive to something like
  [% 'My nice title' | $HtmlTags tag="h1" attributes='title="This is a nice title attribute"' %]
- Verify that title attribute displays in output (source code or tooltip on 'My nice title')

Notes: - Tests are planned for a second patch
       - Update for Wiki coding guidelines

Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18835: Fix SQL syntax error in overdue_notices.pl
Jonathan Druart [Wed, 21 Jun 2017 13:59:57 +0000 (10:59 -0300)]
Bug 18835: Fix SQL syntax error in overdue_notices.pl

Caused by bug 17952, an extra / is in the middle of the query.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18651: Fix tests if no circ rule exist
Jonathan Druart [Wed, 21 Jun 2017 14:05:59 +0000 (11:05 -0300)]
Bug 18651: Fix tests if no circ rule exist

The following test is failing on Jenkins:
 # Subtest: Handle ids duplication
    1..4
    ok 1 - No account lines should exist on old issue_id
    not ok 2 - Two account lines should exist on new issue_id
    ok 3 - AddReturn should return the issue with the new issue_id
    ok 4 - If an item is checked-in, it should be moved to old_issues even if the issue_id already existed in the table
not ok 4 - Handle ids duplication

When no circ rule exist

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18651: [QA Follow-up] Fix the MAX(issue_id) calculation
Marcel de Rooy [Tue, 20 Jun 2017 13:03:35 +0000 (15:03 +0200)]
Bug 18651: [QA Follow-up] Fix the MAX(issue_id) calculation

Found this by inserting the same issue_id in old_issues before checkin:
The call to ->search( )->get_column is in scalar context and will
return the number of results, i.e. always 1.
If you have an issue_id 2 in old_issues, it will crash:
    DBIx::Class::Storage::DBI::_dbh_execute(): Duplicate entry '2' for key 'PRIMARY'

The fix is fairly simple: Put get_column in list context and pick the first
array entry.
NOTE: Using DBIx's get_column()->max here might look simpler here.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18651: [QA Follow-up] Remove unused variable
Marcel de Rooy [Tue, 20 Jun 2017 12:19:12 +0000 (14:19 +0200)]
Bug 18651: [QA Follow-up] Remove unused variable

Variable $original_issue_id is not used. The id is retrieved later from
$issue when updating accountlines.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18651: Limit the life span of the LOCK
Jonathan Druart [Thu, 15 Jun 2017 23:25:18 +0000 (20:25 -0300)]
Bug 18651: Limit the life span of the LOCK

We only need the table to be locked for the fetch, increment, store sequence

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18651: Use a READ and WRITE LOCK
Jonathan Druart [Wed, 24 May 2017 15:24:53 +0000 (12:24 -0300)]
Bug 18651: Use a READ and WRITE LOCK

For more info, see:
  commit be156d9ad9e5bcfadab34d44f90e04fd61e256ad
    Bug 15854: Use a READ and WRITE LOCK on message_queue
and
  commit b40456f7dd4b8a988f9c6a5718452936101cb8ff
    Bug 18364: Do not LOCK/UNLOCK tables from tests

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18651: Copy the row before modify the id
Jonathan Druart [Tue, 23 May 2017 13:27:31 +0000 (10:27 -0300)]
Bug 18651: Copy the row before modify the id

If the "max(issue_id) from old_issue + 1" already exists in issues, the
move fails.

For instance we have
1, 2, 3, 4 in issues

checkin 4
1, 2, 3 in issues (AI=5)
4 in old_issues

Restart mysql => AI is reset to MAX(issue_id) => 4

checkout a new one
1, 2, 3, 4 in issues (AI=5)
4 in old_issues

checkin 4 (will get id 5 in old_issues)
1, 2, 3 in issues (AI=5)
4, 5 in old_issues

=> This works with and without this patch

Now we have
1, 2, 3 in issues (AI=5)
4, 5 in old_issues

Restart mysql => AI is reset to MAX(issue_id) => 4

checkout 2 new ones
1, 2, 3, 4, 5 in issues (AI=7)
4, 5 in old_issues

checkin 4 (4 becomes 6 in old_issues)
1, 2, 3, 5 in issues (AI=6)
4, 5, 6 in old_issues

=> This did not work without with patch
The update of the issue_id was made before the move (so in the issues
table), the PK did not allow it

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18651: Update accountlines.issue_id is the issue_id has been changed during the...
Jonathan Druart [Mon, 22 May 2017 17:30:48 +0000 (14:30 -0300)]
Bug 18651: Update accountlines.issue_id is the issue_id has been changed during the move

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18651: Do not charge if the checkin failed
Jonathan Druart [Mon, 22 May 2017 17:26:25 +0000 (14:26 -0300)]
Bug 18651: Do not charge if the checkin failed

2. If the move fails for whatever reason (see
https://lists.katipo.co.nz/pipermail/koha/2017-May/048045.html for an
example), fines can be charged. It should not

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18651: Update issue_id in AddReturn
Jonathan Druart [Mon, 22 May 2017 15:02:20 +0000 (12:02 -0300)]
Bug 18651: Update issue_id in AddReturn

1. AddReturn returns a $issue hashref with the old issue_id value
=> At first glance it does not affect anything, but would be good to fix
it for future uses.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18582 - Hide empty rows in detailed suggestion view
Owen Leonard [Thu, 11 May 2017 16:45:42 +0000 (16:45 +0000)]
Bug 18582 - Hide empty rows in detailed suggestion view

This patch adds a check for the existence of various template variables
before showing the row containing that data. This will prevent the
display of rows containing labels but no data in the suggestions
detailed view.

To test, apply the patch and go to Acquisitions -> Suggestions.

View the detail page of various suggestions and confirm that only fields
with data are displaying.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18697: Final polishing
Marcel de Rooy [Wed, 31 May 2017 14:19:35 +0000 (16:19 +0200)]
Bug 18697: Final polishing

GetFictiveIssueNumber:
Returns undef instead of 0 for irregular frequencies. Also added to POD.
Removed unused variable $wkno.
Adding a return makes the if(unit) unneeded.
Replaced (a+b)/b by 1+a/b.

_delta_units:
Added a comment about its parameters.

GetFictiveIssueNumber.t:
Adjusted the tests for irregular frequencies accordingly.

Test plan:
[1] Run t/db_dependent/Serials/GetFictiveIssueNumber.t
[2] Run t/db_dependent/Serials/GetNextDate.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18697: Adjusting unit tests for dayly serial frequencies
Marcel de Rooy [Wed, 31 May 2017 13:20:40 +0000 (15:20 +0200)]
Bug 18697: Adjusting unit tests for dayly serial frequencies

No changes were needed for GetNextDate.t.
In GetFictiveIssueNumber.t we add a subtest for daily frequencies.

Test plan:
[1] Run t/db_dependent/Serials/GetFictiveIssueNumber.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18697: Fix date calculation for dayly frequencies in Serials
Marcel de Rooy [Tue, 30 May 2017 14:44:46 +0000 (16:44 +0200)]
Bug 18697: Fix date calculation for dayly frequencies in Serials

The changes in _get_next_date_day are actually only cosmetic. The sub
now reads exactly the same as its counterparts for other units, but
the results are exactly the same as before.

In GetFictiveIssueNumber we now call _delta_units for each type of unit.
The two Delta_Days calls are moved to _delta_units. Note that this also
is a cosmetic change; results should be exactly the same.

Test plan:
[1] Edit a subscription. Test predication pattern for some daily freq.
[2] Run t/db_dependent/GetNextDate.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18697: Adjusting unit tests for weekly serial frequencies
Marcel de Rooy [Tue, 30 May 2017 13:56:22 +0000 (15:56 +0200)]
Bug 18697: Adjusting unit tests for weekly serial frequencies

Corrections and added unit tests following the changes of the first patch.

GetFictiveIssueNumber.t: New subtest for weekly frequencies.

GetNextDate.t: Correcting a few dates one day. If we use 2/week, we will
calculate an interval of 3 days and correct with 4 days at the end of
the cycle. The connection with firstacqui is not relevant anymore.

Test plan:
[1] Run t/db_dependent/Serials/GetFictiveIssueNumber.t
[2] Run t/db_dependent/Serials/GetNextDate.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18697: Fix date calculations for weekly frequencies in Serials
Marcel de Rooy [Tue, 30 May 2017 13:01:52 +0000 (15:01 +0200)]
Bug 18697: Fix date calculations for weekly frequencies in Serials

Same solution applied as in bug 18356/18607. Consistency++

The code in _get_next_date_week is again very similar to the code in
_get_next_date_month or _get_next_date_year. I will not merge them here,
but we could consider that in the future.

Code in GetFictiveIssueNo has been adjusted similarly to month and year.

Test plan:
[1] Do not apply this patch. Create a subscription for 3/week.
    When the first issue date is on a Saturday or Sunday, the
    intervals in the prediction pattern are 0,0,7,0,0,7,etc.
    Starting on Wed-Fri 1,1,5,etc. Starting on Mon-Tue 2,2,3,etc.
[2] Apply this patch. Check again.
    The interval should be always 2,2,3 now and no longer depend on the
    day_of_week of first issue date.
[3] Check another weekly frequency with multiple units per issue.
    Say 1 issue/3 weeks.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18607: Adjusting unit tests for monthly serial frequencies
Marcel de Rooy [Mon, 29 May 2017 10:08:40 +0000 (12:08 +0200)]
Bug 18607: Adjusting unit tests for monthly serial frequencies

The changes in the first patch require some corrections as well as
additional test cases.

GetNextDate.t: Since the calculation for multiple issues per unit has
slightly changed, a few dates (day 15 or day 16) have been changed in the
unit test; when we use 2/month, the algorithm now always adds 15 days.
Added a few test descriptions in this regard too.

GetFictiveIssueNumber.t: Add the monthly subtest with two test cases. In
the first case we tests multiple units per issue, and in the second case
we test multiple issues per unit (month).

Test plan:
[1] Run t/db_dependent/Serials/GetFictiveIssueNumber.t
[2] Run t/db_dependent/Serials/GetNextDate.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18607: Fix date calculations for monthly frequencies in Serials
Marcel de Rooy [Tue, 16 May 2017 12:46:55 +0000 (14:46 +0200)]
Bug 18607: Fix date calculations for monthly frequencies in Serials

Similarly to the solution of bug 18356, this patch fixes the date
calculation for monthly frequencies.

The calculation in GetFictiveIssueNumber now makes use of the new
_delta_units sub introduced on bug 18356.

The calculation in _get_next_date_month is also very similar to the one
in _get_next_date_year. I do not merge them here, but this could still
be considered later on. At least consistency is achieved now between
both routines. The connection with firstacquidate has been cut thru
just like for year units.

Test plan:
[1] Without this patch, look at the prediction pattern for a
    subscription with first issue on Feb 21 and 5 per month. The first
    issues will be 21, 22, 23, 24, 25. Then jumping to 21, 23, 25, etc.
[2] Apply the patch. Look at the same prediction pattern. You will now
    see 6 day intervals and a new cycle starting on the 21st.
    So Feb 21, 27, Mar 5, 11, 17 and Mar 21, 27, etc.
[3] Edit an subscription. Try a few other monthly frequencies.
[4] The next patch adjusts related unit tests.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18356: Fix date calculations for yearly frequencies in Serials
Marcel de Rooy [Tue, 9 May 2017 15:01:46 +0000 (17:01 +0200)]
Bug 18356: Fix date calculations for yearly frequencies in Serials

The problem as described on BZ 18356 is a combination of an error in
GetFictiveIssueNumber and GetNextDate for unit==year.

[1] In GetNextDate the Add_Delta_YM calculation should be applied only to
frequencies based on years per unit.
In the case of multiple units per year we calculate the number of days to
add. And if we have reached the end of a cycle, we correct the
rounding applied in the cycle.
NOTE 1: We obsolete the idea here of rebasing dates on firstacqui. In case
of manual adjustments, we probably do not want it. And otherwise we do not
need it anymore due to the correction at the end of a cycle.
NOTE 2: The calls to Add_Delta_YM are intentionally not corrected for leap
years. Say you start at 2016-02-29. If you use 1/yr or 1/2yr, you will
switch to the Feb 28th in the following years. In 2020 there will be no
switch to Feb 29 again; if someone should need it, please use a manual
adjustment. This is probably highly exceptional.

[2] In GetFictiveIssueNumber the year should be decreased by one if you
have more units per year and you did not yet reach firstacqui day and
month. This affects calculations in GetNextDate with irregularities.
NOTE 1: I added a wrapper around Date::Calc::N_Delta_YMD in order to improve
its results; this will especially be needed when we use it later for
month units.
NOTE 2: In case of manual adjustments this calculation does not really make
sense. Another report should deal with improving irregularities.

Test plan:
[1] Verify that both GetNextDate.t as well as GetFictiveIssueNumber.t pass.
[2] Look at the prediction pattern for a few frequencies.
    For example: 1 iss/y, 1 iss/2y, 5 iss/y.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18356: Extend GetNextDate.t, add GetFictiveIssueNumber.t (unit=year)
Marcel de Rooy [Thu, 11 May 2017 08:47:22 +0000 (10:47 +0200)]
Bug 18356: Extend GetNextDate.t, add GetFictiveIssueNumber.t (unit=year)

This patch deals with tests for yearly frequencies.

Adjust/extend GetNextDate.t:
[1] Adjust mixup of units/issues in a description.
[2] Add testing +2 years on 29-2 of leap year for freq 1 issue/2 years.
[3] Add tests for freq 9 issues/year.

Add GetFictiveIssueNumber.t:
[1] Two subtests are provided for irregular frequencies (very trivial) and
    for year frequencies (with four specific test cases).

Test plan:
[1] Run t/db_dependent/Serials/GetNextDate.t
[2] Run t/db_dependent/Serials/GetFictiveIssueNumber.t

Note: Without the second patch both tests should fail. This shows the need
of the adjustments in the second patch.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18807: t/db_dependent/www/batch.t fails
Mark Tompsett [Thu, 15 Jun 2017 22:07:53 +0000 (18:07 -0400)]
Bug 18807: t/db_dependent/www/batch.t fails

get() does not take two parameters. fixed.
prove and run koha qa test tools

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18807: Fix tests www/batch.t
Jonathan Druart [Wed, 14 Jun 2017 19:56:13 +0000 (16:56 -0300)]
Bug 18807: Fix tests www/batch.t

Several things are wrong here:
1. It assumes that import_record_id is the biblionumber
=> Wrong, it is only true when the DB is empty and that the 2 AI equal 1
2. The encoding in the template is 'UTF-8', not 'utf8', it leaded to
  "stage-marc-import.pl: marc21record.mrc: Unexpected charset UTF-8, expecting utf8"
3. We did not test that the biblio was correctly imported

Test plan:
Make sure the tests now pass.
For the www tests you need to set the following env vars:
KOHA_USER, KOHA_PASS, KOHA_INTRANET_URL and KOHA_OPAC_URL

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18806: Fix batch revert
Jonathan Druart [Wed, 14 Jun 2017 18:53:18 +0000 (15:53 -0300)]
Bug 18806: Fix batch revert

Since bug 18242: When a biblio is deleted, a new transaction is created.
tools/manage-marc-import.pl use the AutoCommit flag, which does not
allow nested transaction.
AutoCommit must not be used.

Test plan:
Import a batch, then revert it.
The biblios must have been correctly deleted, they were not before this
patch

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18703 - Followup, fix typo "statment"
Josef Moravec [Tue, 6 Jun 2017 08:09:19 +0000 (08:09 +0000)]
Bug 18703 - Followup, fix typo "statment"

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
6 years agoBug 18703 - Translatability: Resolve some remaining %%] problems for staff client...
Marc Véron [Tue, 30 May 2017 18:44:30 +0000 (20:44 +0200)]
Bug 18703 - Translatability: Resolve some remaining %%] problems for staff client in 6 Files

There are some more files that expose parts of tt diretives to translations, mostly due to
line breaks inside directives.

Files covered with this Bug:

koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc
 koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc
koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt
koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt

To test:
- Review code, verify that line breaks are removed
- Run QA tools
- Bonus test: Create a "language" aa-AA and verify that no fragments
  containign %%] are picked for the 6 files

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
6 years agoBug 18699: Get rid of %%] in translation for edi_accounts.tt
Marc Véron [Tue, 30 May 2017 14:08:32 +0000 (16:08 +0200)]
Bug 18699: Get rid of %%] in translation for edi_accounts.tt

Translation for edi_accounts.tt exposes:
[%% transport_types = [ 'FTP', 'SFTP', 'FILE' ] %%]

Translators should not be confronted with such code internals.

To test:
- Review code change (it removes line breaks)
- Bonus test: Create a new translatin for "language" aa-AA and
  verify that the line no longer appears in aa-AA-staff-prog.po

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
6 years agoBug 18804: Add additional information to execute successfuly selenium tests
Jonathan Druart [Fri, 16 Jun 2017 20:00:23 +0000 (17:00 -0300)]
Bug 18804: Add additional information to execute successfuly selenium tests

6 years agoBug 18804: (bug 13501 follow-up) Fix add item form (select2)
Jonathan Druart [Wed, 14 Jun 2017 16:08:43 +0000 (13:08 -0300)]
Bug 18804: (bug 13501 follow-up) Fix add item form (select2)

Hard to say here, select2 adds so many elements that we need to ignore.
Here we just assume that input text with an id starting with
tag_952_subfield must be filled

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18804: (bugs 16400,11088 follow-up) Update the "save category" elt selector
Jonathan Druart [Wed, 14 Jun 2017 16:08:20 +0000 (13:08 -0300)]
Bug 18804: (bugs 16400,11088 follow-up) Update the "save category" elt selector

With bug 11088 and bug 16400 the submit node switched from:
  <input type="submit" name="save" onclick="return check_form_borrowers();" value="Save" />
to:
  <button type="submit" name="save" onclick="return check_form_borrowers">
then finally to:
  <button class="btn btn-small" id="saverecord" type="submit" name="save" onclick="return check_form_borrowers();">

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18804: (bug 16286 follow-up) Update the "save category" elt selector
Jonathan Druart [Wed, 14 Jun 2017 16:07:41 +0000 (13:07 -0300)]
Bug 18804: (bug 16286 follow-up) Update the "save category" elt selector

Bug 16286 replaced the submit node:
  <input type="button" value="Save" onclick="Check(this.form);" />
with
  <input type="submit" value="Save" />

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18804: Skip selenium tests if Selenium::Remote::Driver is not installed
Jonathan Druart [Tue, 13 Jun 2017 20:43:39 +0000 (17:43 -0300)]
Bug 18804: Skip selenium tests if Selenium::Remote::Driver is not installed

We do not want these tests to fail if the module is not installed.
This module is not in the dependencies of Koha and it is good as it.
A developper who wants to use it will know what to do.
It is part of RM duties to make sure these tests pass

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18361: [QA Follow-up] Resolve warning on undef values supplied
Marcel de Rooy [Fri, 16 Jun 2017 05:57:14 +0000 (07:57 +0200)]
Bug 18361: [QA Follow-up] Resolve warning on undef values supplied

The following warning was raised in Letters.t:
DBIx::Class::ResultSource::_minimal_valueset_satisfying_constraint():
NULL/undef values supplied for requested unique constraint 'primary' (NULL
values in column(s): 'id'). This is almost certainly not what you wanted,
though you can set DBIC_NULLABLE_KEY_NOWARN to disable this warning.

This warning is triggered by this line in C4/Letters.pm:
    Koha::SMS::Providers->find( $member->{'sms_provider_id'} );
As you already guessed, the sms_provider_id returns undef.

Resolved in sub find by testing if there are parameters and if so, they
should not be all undefined. (In most cases there will be only one
parameter; but this report is about composite keys.)

Added a trivial test case in Objects.t too.

Test plan:
Run t/db_dependent/Koha/Object.t
Run t/db_dependent/Koha/Objects.t
Run t/db_dependent/Letters.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
6 years agoBug 18361: (QA followup) Add tests for the no params case
Tomas Cohen Arazi [Wed, 19 Apr 2017 14:57:33 +0000 (11:57 -0300)]
Bug 18361: (QA followup) Add tests for the no params case

This patch adds a test for the trivial case in which no param is passed
and the ->find method returns undef.

For completeness purposes.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18361: Additional tests for Koha::Objects->find
Marcel de Rooy [Thu, 13 Apr 2017 11:15:30 +0000 (13:15 +0200)]
Bug 18361: Additional tests for Koha::Objects->find

Adding a subtest find in t/db_dependent/Koha/Objects.t.

Test plan:
Run t/db_dependent/Koha/Objects.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18361: Koha::Objects->find should accept composite primary keys
Marcel de Rooy [Fri, 31 Mar 2017 11:52:15 +0000 (13:52 +0200)]
Bug 18361: Koha::Objects->find should accept composite primary keys

Changes the $id parameter to an array. (IssuingRule has three keys.)
The build_object method in TestBuilder.pm has been adjusted to pass
multiple primary key values to find.

Also adjusted the POD section to show more clearly that we accept
the same parameters as DBIx ResultSet does.

Test plan:
Run t/db_dependent/Koha/Object.t
Run t/db_dependent/Koha/Objects.t
Run t/db_dependent/TestBuilder.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18539: remove occurrence in ReNewSubscription.t
Jonathan Druart [Thu, 15 Jun 2017 18:46:17 +0000 (15:46 -0300)]
Bug 18539: remove occurrence in ReNewSubscription.t

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 18539: Forbid list context calls for Koha::Objects->find
Jonathan Druart [Tue, 18 Apr 2017 16:49:18 +0000 (13:49 -0300)]
Bug 18539: Forbid list context calls for Koha::Objects->find

Reading https://perlmaven.com/how-to-return-undef-from-a-function
this sound like the more correct behaviour.

Considering:
$template->param(
    stuff => Koha::Stuffs->find( $id ),
    foo   => 1,
);
without this patch, if the $id does not represent any rows in the DB,
stuff will be assigned to 'foo' and $foo will be undef in the template.
That can lead to very bad side-effects.

With this patch we make sure that it will never happen again.

Test plan:
  prove t/db_dependent/Koha/Objects.t
should return green

Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 17975: Let C4::Letters manage today param substitution
Jonathan Druart [Mon, 27 Feb 2017 08:59:53 +0000 (08:59 +0000)]
Bug 17975: Let C4::Letters manage today param substitution

The today parameter is properly handled from C4::Letters subroutines, we
do not need to pass it from callers.

Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
6 years agoBug 17975: TT syntax for notices - Prove that HOLD_SLIP is compatible
Jonathan Druart [Mon, 16 Jan 2017 16:33:39 +0000 (17:33 +0100)]
Bug 17975: TT syntax for notices - Prove that HOLD_SLIP is compatible

Here we need to test <<today>>.
We already pass a value, but it was wrong. We must pass a string, not a
DateTime object, otherwise the KohaDates plugin will not display the
hours part if we need it.

Test plan:
Define a HOLD_SLIP notice template to match your need.
Do not forget to use
  [% today | $KohaDates %]
or
  [% today | $KohaDates with_hours => 1 %]
To access data from the reserves table, use the 'hold' variable

Tested both patches together with several date formats, works as expected.
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>