From 18e4a4bb88f06396986d2a0cc36ddf0a3172a81d Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 13 Jun 2017 01:28:26 +0000 Subject: [PATCH] Bug 14367: (follow-up) Fixing merge conflicts... ...and other fixes to make patch work. --- C4/Biblio.pm | 6 +++--- Koha/MetadataRecord/History.pm | 4 ++-- installer/data/mysql/atomicupdate/add_history.sql | 1 - .../data/mysql/atomicupdate/bug_14367_-_add_history_column.perl | 9 +++++++++ 4 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/add_history.sql create mode 100644 installer/data/mysql/atomicupdate/bug_14367_-_add_history_column.perl diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 2deab9a1e4..41dad30553 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -302,7 +302,7 @@ sub ModBiblio { # update biblionumber and biblioitemnumber in MARC # FIXME - this is assuming a 1 to 1 relationship between # biblios and biblioitems - my $sth = $dbh->prepare("select biblioitemnumber,history from biblioitems where biblionumber=?"); + my $sth = $dbh->prepare("select biblioitems.biblioitemnumber, biblio_metadata.history from biblioitems, biblio_metadata where biblioitems.biblionumber=?"); $sth->execute($biblionumber); my ($biblioitemnumber, $history) = $sth->fetchrow; $sth->finish(); @@ -3211,8 +3211,8 @@ sub ModBiblioMarc { my $newhistory = HistoryUpdate($newrecord, $historylength, $history); $newhistory = encode_json($newhistory); - $sth = $dbh->prepare("UPDATE biblioitems SET marc=?,marcxml=?,history=? WHERE biblionumber=?"); - $sth->execute( $record->as_usmarc(), $record->as_xml_record($encoding), $newhistory, $biblionumber ); + $sth = $dbh->prepare("UPDATE biblio_metadata SET metadata=?,history=? WHERE biblionumber=?"); + $sth->execute( $record->as_xml_record($encoding), $newhistory, $biblionumber ); $sth->finish; ModZebra( $biblionumber, "specialUpdate", "biblioserver", $record ); diff --git a/Koha/MetadataRecord/History.pm b/Koha/MetadataRecord/History.pm index 2a4e04addf..66798db504 100644 --- a/Koha/MetadataRecord/History.pm +++ b/Koha/MetadataRecord/History.pm @@ -68,10 +68,10 @@ sub GetMarcBiblioHistory { return; } my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("SELECT marcxml,history FROM biblioitems WHERE biblionumber=? "); + my $sth = $dbh->prepare("SELECT metadata,history FROM biblio_metadata WHERE biblionumber=? "); $sth->execute($biblionumber); my $row = $sth->fetchrow_hashref; - my $marcxml = StripNonXmlChars( $row->{'marcxml'} ); + my $marcxml = StripNonXmlChars( $row->{'metadata'} ); MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); my $record = MARC::Record->new(); my ($history, $borrowers) = HistoryParse( $row->{'history'} ); diff --git a/installer/data/mysql/atomicupdate/add_history.sql b/installer/data/mysql/atomicupdate/add_history.sql deleted file mode 100644 index 4c5c424e6e..0000000000 --- a/installer/data/mysql/atomicupdate/add_history.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE biblioitems ADD COLUMN `history` LONGTEXT DEFAULT NULL AFTER `marcxml`; diff --git a/installer/data/mysql/atomicupdate/bug_14367_-_add_history_column.perl b/installer/data/mysql/atomicupdate/bug_14367_-_add_history_column.perl new file mode 100644 index 0000000000..b8a1af42fb --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_14367_-_add_history_column.perl @@ -0,0 +1,9 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + unless( column_exists( 'biblio_metadata', 'history' ) ) { + $dbh->do(q|ALTER TABLE biblio_metadata ADD history longtext default NULL AFTER metadata|); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 14367: Add column biblio_metadata.history)\n"; +} -- 2.11.0