From d86893da5e5b2af70663041b9e232956eff43ae7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 14 Mar 2025 16:28:26 +0000 Subject: [PATCH] Bug 38330: (QA follow-up) Add population of opac_suppressed from biblio_metadata This patch updates the database update to populate the new opac_suppressed field in the bilios table using the data in the biblio_metadata table. Signed-off-by: Martin Renvoize --- .../data/mysql/atomicupdate/bug_38330.pl | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/installer/data/mysql/atomicupdate/bug_38330.pl b/installer/data/mysql/atomicupdate/bug_38330.pl index b5f006b42f3..9e04f141b28 100755 --- a/installer/data/mysql/atomicupdate/bug_38330.pl +++ b/installer/data/mysql/atomicupdate/bug_38330.pl @@ -15,6 +15,21 @@ return { ADD COLUMN `opac_suppressed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'whether the record should be suppressed in the OPAC' AFTER `abstract`; } ); + + $dbh->do( + q{ + UPDATE biblio b + JOIN biblio_metadata m ON b.biblionumber = m.biblionumber + SET b.opac_suppressed = + CASE + WHEN ExtractValue(m.metadata, '//datafield[@tag="952"]/subfield[@code="n"]') REGEXP '^[01]$' THEN + ExtractValue(m.metadata, '//datafield[@tag="952"]/subfield[@code="n"]') + ELSE 0 + END + WHERE m.metadata LIKE '%%'; + } + ); + say $out "Added column 'biblio.opac_suppressed'"; } @@ -25,6 +40,21 @@ return { ADD COLUMN `opac_suppressed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'whether the record should be suppressed in the OPAC' AFTER `abstract`; } ); + + $dbh->do( + q{ + UPDATE deletedbiblio b + JOIN deletedbiblio_metadata m ON b.biblionumber = m.biblionumber + SET b.opac_suppressed = + CASE + WHEN ExtractValue(m.metadata, '//datafield[@tag="952"]/subfield[@code="n"]') REGEXP '^[01]$' THEN + ExtractValue(m.metadata, '//datafield[@tag="952"]/subfield[@code="n"]') + ELSE 0 + END + WHERE m.metadata LIKE '%%'; + } + ); + say $out "Added column 'deletedbiblio.opac_suppressed'"; } @@ -33,6 +63,7 @@ return { UPDATE marc_subfield_structure SET kohafield='biblio.opac_suppressed' WHERE tagfield=942 AND tagsubfield='n'; } ); + say $out "Set the 942\$n => biblio.opac_suppressed mapping for all MARC frameworks"; say_warning( $out, "You need to run the `maintenance/touch_all_biblios.pl` script" ); }, -- 2.48.1