| Summary: | Fix encoding in action_logs.info | ||
|---|---|---|---|
| Product: | Koha | Reporter: | Magnus Enger <magnus> |
| Component: | Cataloging | Assignee: | Bugs List <koha-bugs> |
| Status: | NEW --- | QA Contact: | Testopia <testopia> |
| Severity: | normal | ||
| Priority: | P5 - low | CC: | m.de.rooy |
| Version: | Main | ||
| Hardware: | All | ||
| OS: | All | ||
| 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: | |||
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';
|
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}",