[Bug 43979] New: Importing a MARC framework silently drops subfields whose authorised value category does not exist
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43979 Bug ID: 43979 Summary: Importing a MARC framework silently drops subfields whose authorised value category does not exist Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: System Administration Assignee: koha-bugs@lists.koha-community.org Reporter: adolfo.rodriguez@xercode.es QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com Target Milestone: --- When importing a MARC bibliographic framework (CSV or ODS) from Administration > MARC bibliographic frameworks > Actions > Import, a subfield whose authorised value category does not exist in the installation cannot be saved: the insert fails on the marc_subfield_structure_ibfk_1 foreign key. The error only goes to the logs: - If the framework is new, the subfield is just not created. - If the subfield already existed in the framework, it is deleted: the rows that are not in the file are removed at the end of the import, and a row that failed is treated as "not in the file". In both cases the import is reported as successful and the librarian is sent to the framework structure page with no warning, so the framework ends up silently incomplete. The same happens with any other row that fails to be imported. This is easy to hit when moving a framework between installations that do not have the same authorised value categories. Expected: - The subfield is imported without the authorised value category (which is what the foreign key itself does when a category is deleted: ON DELETE SET NULL). - A row that fails for any other reason does not delete the existing one. - The librarian is told which subfields were affected. -- 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=43979 Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |adolfo.rodriguez@xercode.es |ity.org | -- 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=43979 --- Comment #1 from Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> --- Created attachment 210194 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210194&action=edit Bug 43979: Framework import: do not silently drop subfields with a missing authorised value category When a subfield in an imported MARC framework uses an authorised value category that does not exist, the row failed on the foreign key and the error only went to the logs. The subfield was not created, or, if it already existed, it was deleted at the end of the import, and the import was still reported as successful. This patch: - Imports the subfield without the authorised value category, as the foreign key does when a category is deleted (ON DELETE SET NULL). - Keeps the existing row when a row cannot be imported for any other reason, instead of deleting it. - Collects these problems in an optional parameter of ImportFramework, and shows them on the framework structure page after the import. Steps to follow: 1. Go to Administration > MARC bibliographic frameworks and create a new framework, e.g. code TST. When asked, create its structure from the default framework. 2. Actions > Export for TST, as CSV. Keep that file. 3. Make a copy of the file and open the copy in a text editor. In the row for subfield 952$c ("952","c","Shelving location",...), replace the authorised value category "LOC" with "LOCX" (a category that does not exist). Save it. 4. Actions > Import for TST, choose the copy and confirm. 5. You are redirected to the framework structure with no message. Go to tag 952 > Subfields: subfield c is gone. 6. Apply the patch and restart Plack. 7. Import the original file from step 2 again: 952$c is back. 8. Import the copy from step 3 again: - The structure page shows a warning: "The framework was imported with warnings", listing "952$c: LOCX". - Tag 952 > Subfields: subfield c is still there, with no authorised value. 9. Run the tests: prove t/db_dependent/ImportExportFramework.t 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