From 2e153e0356181c1f2b3f4fb61a22b6730dedb4f8 Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Thu, 4 Nov 2010 16:19:05 -0400 Subject: [PATCH] Bug 5366 - [2/2] Standing enh req for code changes enabling database agnosticism Content-Type: text/plain; charset="utf-8" http://koha-community.org MariaDB apparently will not fudge when one attempts to insert a null value into a NOT NULL field with no default defined. This probably should have been fixed in any case, but must be fixed if Koha is to run over MariaDB. This patch simple supplies a single blank space as the value passed in on the initial insert. --- C4/ImportBatch.pm | 9 ++++----- tools/stage-marc-import.pl | 9 ++++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 15f1acb..fc71069 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -1350,13 +1350,14 @@ sub SetImportRecordMatches { sub _create_import_record { my ($batch_id, $record_sequence, $marc_record, $record_type, $encoding, $z3950random, $marc_type) = @_; + my $marcxml_old = " "; # placeholder because import_records.marcxml_old is NOT NULL with no DEFAULT set my $dbh = C4::Context->dbh; my $sth = $dbh->prepare("INSERT INTO import_records (import_batch_id, record_sequence, marc, marcxml, - record_type, encoding, z3950random) - VALUES (?, ?, ?, ?, ?, ?, ?)"); + marcxml_old, record_type, encoding, z3950random) + VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); $sth->execute($batch_id, $record_sequence, $marc_record->as_usmarc(), $marc_record->as_xml($marc_type), - $record_type, $encoding, $z3950random); + $marcxml_old, $record_type, $encoding, $z3950random); my $import_record_id = $dbh->{'mysql_insertid'}; $sth->finish(); return $import_record_id; @@ -1388,7 +1389,6 @@ sub _add_auth_fields { sub _add_biblio_fields { my ($import_record_id, $marc_record) = @_; - my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record); my $dbh = C4::Context->dbh; # FIXME no controlnumber, originalsource @@ -1396,7 +1396,6 @@ sub _add_biblio_fields { my $sth = $dbh->prepare("INSERT INTO import_biblios (import_record_id, title, author, isbn, issn) VALUES (?, ?, ?, ?, ?)"); $sth->execute($import_record_id, $title, $author, $isbn, $issn); $sth->finish(); - } sub _update_biblio_fields { diff --git a/tools/stage-marc-import.pl b/tools/stage-marc-import.pl index fbb5365..8b3ae50 100755 --- a/tools/stage-marc-import.pl +++ b/tools/stage-marc-import.pl @@ -25,7 +25,12 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; -#use warnings; FIXME - Bug 2505 +use warnings; + +#use Sys::Syslog; #XXX +#openlog('Koha_Import','' ,'LOCAL0'); + +#syslog('debug|local0', "Starting up tools/stage-marc-import.pl"); #XXX # standard or CPAN modules used use CGI; @@ -130,6 +135,8 @@ if ($completedJobID) { } + # open STDERR, '>', "/home/koha/koha.git/var/log/koha-import.log"; # uncomment to log errors from child process; fix path for your install; logfile must be owned by apache user + # FIXME branch code my ($batch_id, $num_valid, $num_items, @import_errors) = BatchStageMarcRecords($record_type, $encoding, $marcrecord, $filename, $comments, '', $parse_items, 0, 50, staging_progress_callback($job, $dbh)); -- 1.7.2.5