Bug 27857: Make Koha::Patron->extended_attributes validate data
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 4 Mar 2021 12:37:42 +0000 (09:37 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 9 Apr 2021 13:43:30 +0000 (15:43 +0200)
commit7b40ee22035210e3fbdfe75785d68ca314285409
tree57006ca94d01e49b77a19bc357c9ac290937626c
parent9e7903dfd6714b22c670acdadc4a030f3e6c2ceb
Bug 27857: Make Koha::Patron->extended_attributes validate data

This patch makes the extended_attributes method use
Koha::Patron->add_extended_attribute inside the loop, instead of direct
DB access. This way, it takes advantage of the validation that is done
there.

All happens inside a transaction, so if 'add_extended_attribute' throws
an exception, everything is rolled back.

To test:
1. Apply the previous patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Patron.t
=> FAIL: The behavior is not the correct one, tests fail
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/Patron.pm