From 22b4acf8d21eefc7d1b0af8091278321907dbb4c Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 8 Jul 2026 12:23:42 +0100 Subject: [PATCH] Bug 35104: Add biblio_metadata_errors table for per-fault error tracking Adds biblio_metadata_errors to record individual faults (non-XML characters, empty datafields, ...) found and recovered when saving a bibliographic record's MARCXML, so they can be surfaced to cataloguers and explicitly resolved once reviewed. Signed-off-by: Baptiste Bayche Signed-off-by: Baptiste Wojtkowski Sponsored-by: OpenFifth Signed-off-by: Nick Clemens Signed-off-by: Pedro Amorim --- .../data/mysql/atomicupdate/bug_35104.pl | 31 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 21 +++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_35104.pl diff --git a/installer/data/mysql/atomicupdate/bug_35104.pl b/installer/data/mysql/atomicupdate/bug_35104.pl new file mode 100755 index 0000000000..0211296d24 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35104.pl @@ -0,0 +1,31 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "35104", + description => "Add biblio_metadata_errors table for normalised error tracking", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + unless ( TableExists('biblio_metadata_errors') ) { + $dbh->do( + q{ + CREATE TABLE `biblio_metadata_errors` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `metadata_id` int(11) NOT NULL COMMENT 'FK to biblio_metadata.id', + `error_type` varchar(64) NOT NULL COMMENT 'Error type identifier, e.g. nonxml_stripped', + `tag` varchar(3) DEFAULT NULL COMMENT 'MARC tag affected, if applicable', + `subfield` varchar(1) DEFAULT NULL COMMENT 'MARC subfield code affected, if applicable', + `message` mediumtext DEFAULT NULL COMMENT 'Error message details', + `created_on` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `biblio_metadata_errors_fk_1` (`metadata_id`), + CONSTRAINT `biblio_metadata_errors_fk_1` FOREIGN KEY (`metadata_id`) REFERENCES `biblio_metadata` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci + } + ); + say_success( $out, "Added new table 'biblio_metadata_errors'" ); + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 9dfb1e1a84..d74a2354a3 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1160,6 +1160,27 @@ CREATE TABLE `biblio_metadata` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `biblio_metadata_errors` +-- + +DROP TABLE IF EXISTS `biblio_metadata_errors`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `biblio_metadata_errors` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `metadata_id` int(11) NOT NULL COMMENT 'FK to biblio_metadata.id', + `error_type` varchar(64) NOT NULL COMMENT 'Error type identifier, e.g. nonxml_stripped', + `tag` varchar(3) DEFAULT NULL COMMENT 'MARC tag affected, if applicable', + `subfield` varchar(1) DEFAULT NULL COMMENT 'MARC subfield code affected, if applicable', + `message` mediumtext DEFAULT NULL COMMENT 'Error message details', + `created_on` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `biblio_metadata_errors_fk_1` (`metadata_id`), + CONSTRAINT `biblio_metadata_errors_fk_1` FOREIGN KEY (`metadata_id`) REFERENCES `biblio_metadata` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `biblioitems` --