[Bug 43907] New: Reverting a staged MARC import deletes the existing items that the import replaced
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43907 Bug ID: 43907 Summary: Reverting a staged MARC import deletes the existing items that the import replaced Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: major Priority: P5 - low Component: MARC Bibliographic record staging/import Assignee: koha-bugs@lists.koha-community.org Reporter: adolfo.rodriguez@xercode.es QA Contact: testopia@bugs.koha-community.org Depends on: 43905 Target Milestone: --- When a staged MARC import is committed with the item action "replace", existing items are replaced: the item is found by its itemnumber (952$9) or by its barcode, and updated. These items already existed before the import, and can be attached to another record. Reverting the batch then deletes the items listed in import_items for each record, but import_items does not distinguish the replaced items from the items created by the import (both have the status 'imported'): - If the item was matched by itemnumber, import_items.itemnumber is the existing item, so reverting the batch DELETES THAT EXISTING ITEM. - If the item was matched by barcode, import_items.itemnumber gets the 952$9 of the incoming file (usually empty) instead of the replaced item, so the item is not deleted, but the link is wrong (and it could point to an unrelated item). To reproduce: 1. Cataloging > Stage records for import: stage a file with a record that matches an existing record (for example by ISBN), with a 952 with the itemnumber (952$9) of an existing item of any record, choosing "Replace items if matching bib was found". 2. Cataloging > Manage staged records: import the batch. 1 item is replaced. 3. Undo the import of the batch: the existing item is deleted (it is now in deleteditems). Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43905 [Bug 43905] Staged MARC import: replacing an item attached to another record does not reindex that record -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43907 Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |adolfo.rodriguez@xercode.es |ity.org | Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43907 --- Comment #1 from Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> --- Created attachment 208987 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208987&action=edit Bug 43907: Do not delete the items replaced by an import when reverting it When a staged MARC import replaced existing items, import_items marked them as 'imported', like the items created by the import. Reverting the batch deletes the 'imported' items, so it deleted items that existed before the import, if they had been matched by itemnumber (952$9). When they had been matched by barcode, the itemnumber stored was the one of the incoming file, usually empty, instead of the replaced item. This patch: - adds the 'replaced' status to import_items.status - stores the replaced items with that status and their real itemnumber, whether they are matched by itemnumber or by barcode - makes BatchRevertItems only delete the items created by the import ('imported'): the replaced items are kept. As before, reverting does not restore their previous data, as Koha does not keep it. Steps to follow: 1. Make sure the background jobs worker is running. 2. Choose an item of any record (record A), and another record B with an ISBN. 3. Create a MARC file with a record that has the ISBN of record B in 020$a, and a 952 with the itemnumber of the item of record A in 952$9 (and 952$a, $b, $p and $y). 4. Cataloging > Stage records for import: stage the file with: - Record matching rule: ISBN - Action if matching record found: Ignore incoming record - Action if no match is found: Ignore incoming record - How to process items: Replace items if matching bib was found 5. Cataloging > Manage staged records: import the batch (1 item is replaced), then undo the import. The item of record A is deleted. 6. Apply the patches, run the database update (perl installer/data/mysql/updatedatabase.pl) and restart_all. 7. Restore an item in record A (or choose another one), update the 952$9 of the file and repeat steps 4 and 5: the item is not deleted. In the database, its import_items row has the status 'replaced' and its itemnumber: SELECT status, itemnumber FROM import_items ORDER BY import_items_id DESC LIMIT 1; 8. Repeat with a 952 without 952$9 and with the barcode of an existing item: import_items has its itemnumber, and undoing the import does not delete it. 9. prove t/db_dependent/ImportBatch.t Signed-off-by: Adolfo Rodríguez <adolfo.rodriguez@xercode.es> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43907 --- Comment #2 from Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> --- Created attachment 208988 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208988&action=edit Bug 43907: DBIC schema changes Signed-off-by: Adolfo Rodríguez <adolfo.rodriguez@xercode.es> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org