Bug 42024 - Fix encoding in action_logs.info
Summary: Fix encoding in action_logs.info
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-03-09 08:36 UTC by Magnus Enger
Modified: 2026-03-09 08:47 UTC (History)
1 user (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Crowdfunding committed: 0
Crowdfunding contact:
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Enger 2026-03-09 08:36:38 UTC
To reproduce: 

- Make sure CataloguingLog is enabled
- Find a record with at least one item, and go to "Edit" for one item
- Add something like this to "x - Non-public note"  and "z - Public note" = "ÆØÅ æøå"
- Edit the same item again, and just save it without doing any changes (we need to do this step for the æøå to show up in the log viewer)
- Verify everything looks OK in the "Normal" view of the record
- Go to Tools > Log viewer
- Select the "Cataloging" module and click on "Submit"
- In the "info" column for the most recent edit, those non-ASCII characters will look like this: 

'itemnotes' => "\x{e6}\x{f8}\x{e5} \x{c6}\x{d8}\x{c5}", 
'itemnotes_nonpublic' => "\x{e6}\x{f8}\x{e5} \x{c6}\x{d8}\x{c5}"

Maybe a problem with how we turn the item data into JSON before we save it to action_logs.info? 

The item data looks OK in the database: 

MariaDB [koha_kohadev]> select itemnotes, itemnotes_nonpublic from items where itemnumber = 578;
+---------------+---------------------+
| itemnotes     | itemnotes_nonpublic |
+---------------+---------------------+
| æøå ÆØÅ       | æøå ÆØÅ             |
+---------------+---------------------+

In action_logs, "diff" looks OK: 

diff: {"D":{"itemnotes_nonpublic":{"O":null,"N":"æøå ÆØÅ"},"cn_sort":{"O":"_","N":""},"itemnotes":{"O":null,"N":"æøå ÆØÅ"},"cn_source":{"O":null,"N":"ddc"},"timestamp":{"N":"2026-03-09 08:18:54","O":"2020-01-29 13:06:23"}}}

But "info" is not OK: 

     info: item $VAR1 = {
...
  'itemnotes' => "\x{e6}\x{f8}\x{e5} \x{c6}\x{d8}\x{c5}",
  'itemnotes_nonpublic' => "\x{e6}\x{f8}\x{e5} \x{c6}\x{d8}\x{c5}",
Comment 1 Magnus Enger 2026-03-09 08:47:16 UTC
Looks like this code in C4::Log::logaction() is responsible for producing the contents of "info": 

 90         if ( $infos->isa('Koha::Item') && $modulename eq 'CATALOGUING' && $actionname eq 'MODIFY' ) {
 91             $infos = "item " . Dumper( $original->unblessed );

The "diff" is done with encode_json:

140     $diff //= encode_json( diff( $original, $updated, noU => 1 ) )
141         if $original && ref $updated eq 'HASH';