Koha-clms/t
Martin Renvoize f4db130ad4
Bug 40136: (follow-up) Unify patron log entries when attributes change with patron data
Three issues were reported with patron action logging:

1. CREATE followed by extended_attributes() produced two log entries
   (CREATE for patron fields + MODIFY for attributes) instead of one.
2. MODIFY that changed both regular fields and patron attributes produced
   two separate MODIFY entries instead of one unified entry.
3. DELETE log did not include the patron's extended attribute values.

Fix:
- logaction() now explicitly returns the stored Koha::ActionLog object so
  callers can capture the action_id.
- Koha::Patron::store() saves the action_id of the CREATE or MODIFY log it
  writes into $self->{_patron_log_id}.
- Koha::Patron::extended_attributes() setter checks for _patron_log_id. If
  set, it calls _merge_attribute_log() to fold the attribute changes into
  the existing log entry (updating its info and diff JSON) instead of
  creating a new MODIFY entry. This covers both the CREATE and MODIFY cases.
- Koha::Patron::delete() now iterates extended_attributes before deletion
  and adds attribute.CODE keys to the patron_data snapshot, so the DELETE
  diff includes the removed attributes.
- New private helper _merge_attribute_log() decodes an existing action log
  entry's info/diff JSON, merges in the attribute change data using
  Struct::Diff, and saves the updated entry.
- Tests added to t/db_dependent/Koha/Patrons.t covering all three scenarios.

Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
2026-03-23 10:46:22 +01:00
..
Acquisition Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Biblio Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Budgets Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Circulation Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
External Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Koha Bug 41107: Add /status/version API endpoint 2026-03-23 09:33:54 +01:00
Number Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
SIP Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Search Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
Serials Bug 41330: Unit tests 2026-03-09 17:06:49 -06:00
Template Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Test Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
cypress Bug 23415: Add debt override support to circulation checkout page 2026-03-22 23:27:26 +01:00
data Bug 41032: Fix Open Fifth missing in plugin repos config 2025-11-26 10:40:25 -07:00
db_dependent Bug 40136: (follow-up) Unify patron log entries when attributes change with patron data 2026-03-23 10:46:22 +01:00
edi_testfiles
…
etc
…
lib Bug 36542: Update unit test 2026-03-05 08:33:41 -07:00
mock_templates Bug 38365: Adjust t/mock_templates/opac-tmpl/bootstrap/en/modules/opac-csp.tt 2026-03-16 11:57:43 +01:00
00-check-atomic-updates.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
00-load.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
00-merge-conflict-markers.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
00-testcritic.t Bug 38944: Revert changes to t/00-testcritic.t 2025-03-13 17:25:06 +01:00
00-valid-xml.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
Auth.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
AuthoritiesMarc_MARC21.t Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
AuthoritiesMarc_UNIMARC.t Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
Barcodes_EAN13.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Barcodes_annual.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Barcodes_hbyymmincr.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Barcodes_incremental.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Biblio.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Biblio2.t Bug 38944: Manual changes 2025-03-13 17:25:04 +01:00
Breeding.t Bug 40017: (follow-up) Update GNU license link 2025-10-22 07:42:53 -06:00
Budgets.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Charset.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Circulation_barcodedecode.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ClassSortRoutine.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
ClassSortRoutine_Dewey.t Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
ClassSortRoutine_Generic.t Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
ClassSortRoutine_LCC.t Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
ClassSource.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Context.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Contract.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
CookieManager.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Creators.t Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
DateUtils.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
EdiInvoice.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Edifact.t Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
Ediorder.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Ediordrsp.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Form_MessagingPreferences.t Bug 34776: Add unit tests for sub restore_form_values 2025-06-30 08:30:51 -06:00
HtmlTags.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
ImportBatch.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Installer_PerlModules.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
ItemCirculationAlertPreference.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Koha_MetadataRecord.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Koha_SearchEngine_Elasticsearch_Browse.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Koha_Template_Plugin_HtmlId.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Koha_Template_Plugin_Koha.t Bug 41107: (follow-up) Use Koha::Status in Koha::Template::Plugin::Koha 2026-03-23 09:33:54 +01:00
Koha_Util_FrameworkPlugin.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Koha_Util_MARC.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Koha_XSLT_HTTPS.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Labels.t Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
Labels_split_Regex.t Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
Labels_split_ccn.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Labels_split_ddcn.t Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
Labels_split_lccn.t Bug 40680: Fix t/Labels* 2025-12-01 08:34:00 -07:00
Languages.t Bug 39745: Replace more occurrences in selenium tests 2026-02-09 12:57:59 -07:00
Logger.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Makefile.t Bug 40527: Add SECURITY.md to ignored list in MakeFile.t 2025-10-09 16:47:28 -06:00
Members_Messaging.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
OpenLibrarySearch.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Output.t Bug 30261: Update unit tests 2026-03-20 11:54:32 +00:00
Output_JSONStream.t Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
Patroncards.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Patroncards_Batch.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Patroncards_Lib.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Patroncards_Patroncard.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Patroncards_Profile.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Patroncards_Template.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
RecordProcessor.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Ris.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
SMS.t Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
Scheduler.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Scrubber.t Bug 39860: Update scrubber profile and add Scrubber.t test 2025-11-03 14:13:47 -07:00
Search.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Search_PazPar2.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
SimpleMARC.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
SuggestionEngine.t Bug 38944: Manual changes 2025-03-13 17:25:04 +01:00
SuggestionEngine_AuthorityFile.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
TmplToken.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Token.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
template_filters.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
timezones.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00