Bugzilla – Attachment 87839 Details for
Bug 22532
Remove "random" from Z39.50
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22532: Remove Z39.50 random
Bug-22532-Remove-Z3950-random.patch (text/plain), 11.02 KB, created by
Marcel de Rooy
on 2019-04-12 06:01:43 UTC
(
hide
)
Description:
Bug 22532: Remove Z39.50 random
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2019-04-12 06:01:43 UTC
Size:
11.02 KB
patch
obsolete
>From 49c3b9b62747f2d2559f97635ee9e5644e3278ef Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Mon, 18 Mar 2019 16:46:00 +0000 >Subject: [PATCH] Bug 22532: Remove Z39.50 random >Content-Type: text/plain; charset=utf-8 > >Test plan: >Try to search, preview and import authority from Z39.50, everything >should work as expected > >Signed-off-by: Hayley Mapley <hayleymapley@catalyst.net.nz> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Breeding.pm | 66 +++++++++++++++------------------------- > C4/ImportBatch.pm | 18 +++++------ > cataloguing/z3950_auth_search.pl | 1 - > 3 files changed, 32 insertions(+), 53 deletions(-) > >diff --git a/C4/Breeding.pm b/C4/Breeding.pm >index 9afd2f123d..8f3e4a8c69 100644 >--- a/C4/Breeding.pm >+++ b/C4/Breeding.pm >@@ -48,7 +48,7 @@ C4::Breeding : module to add biblios to import_records via > =head1 SYNOPSIS > > Z3950Search($pars, $template); >- ($count, @results) = &BreedingSearch($title,$isbn,$random); >+ ($count, @results) = &BreedingSearch($title,$isbn); > > =head1 DESCRIPTION > >@@ -57,10 +57,9 @@ cataloguing reservoir features. > > =head2 BreedingSearch > >-($count, @results) = &BreedingSearch($title,$isbn,$random); >+($count, @results) = &BreedingSearch($title,$isbn); > C<$title> contains the title, > C<$isbn> contains isbn or issn, >-C<$random> contains the random seed from a z3950 search. > > C<$count> is the number of items in C<@results>. C<@results> is an > array of references-to-hash; the keys are the items from the C<import_records> and >@@ -69,7 +68,7 @@ C<import_biblios> tables of the Koha database. > =cut > > sub BreedingSearch { >- my ($search,$isbn,$z3950random) = @_; >+ my ($search,$isbn) = @_; > my $dbh = C4::Context->dbh; > my $count = 0; > my ($query,@bind); >@@ -84,25 +83,20 @@ sub BreedingSearch { > JOIN import_records USING (import_record_id) > JOIN import_batches USING (import_batch_id) > WHERE "; >- if ($z3950random) { >- $query .= "z3950random = ?"; >- @bind=($z3950random); >- } else { >- @bind=(); >- if (defined($search) && length($search)>0) { >- $search =~ s/(\s+)/\%/g; >- $query .= "title like ? OR author like ?"; >- push(@bind,"%$search%", "%$search%"); >- } >- if ($#bind!=-1 && defined($isbn) && length($isbn)>0) { >- $query .= " and "; >- } >- if (defined($isbn) && length($isbn)>0) { >- $query .= "isbn like ?"; >- push(@bind,"$isbn%"); >- } >+ @bind=(); >+ if (defined($search) && length($search)>0) { >+ $search =~ s/(\s+)/\%/g; >+ $query .= "title like ? OR author like ?"; >+ push(@bind,"%$search%", "%$search%"); > } >- $sth = $dbh->prepare($query); >+ if ($#bind!=-1 && defined($isbn) && length($isbn)>0) { >+ $query .= " and "; >+ } >+ if (defined($isbn) && length($isbn)>0) { >+ $query .= "isbn like ?"; >+ push(@bind,"$isbn%"); >+ } >+ $sth = $dbh->prepare($query); > $sth->execute(@bind); > while (my $data = $sth->fetchrow_hashref) { > $results[$count] = $data; >@@ -307,9 +301,7 @@ sub _handle_one_result { > ( $marcrecord, $error ) = _do_xslt_proc($marcrecord, $servhref, $xslh); > > my $batch_id = GetZ3950BatchId($servhref->{servername}); >- my $breedingid = AddBiblioToBatch($batch_id, $seq, $marcrecord, 'UTF-8', 0, 0); >- #FIXME passing 0 for z3950random >- #Will eliminate this unused field in a followup report >+ my $breedingid = AddBiblioToBatch($batch_id, $seq, $marcrecord, 'UTF-8', 0); > #Last zero indicates: no update for batch record counts > > >@@ -491,7 +483,7 @@ sub _translate_query { #SRU query adjusted per server cf. srufields column > > =head2 ImportBreedingAuth > >-ImportBreedingAuth($marcrecords,$overwrite_auth,$filename,$encoding,$z3950random); >+ImportBreedingAuth($marcrecords,$overwrite_auth,$filename,$encoding); > > ImportBreedingAuth imports MARC records in the reservoir (import_records table). > ImportBreedingAuth is based on the ImportBreeding subroutine. >@@ -499,7 +491,7 @@ ImportBreedingAuth($marcrecords,$overwrite_auth,$filename,$encoding,$z3950random > =cut > > sub ImportBreedingAuth { >- my ($marcrecord,$overwrite_auth,$filename,$encoding,$z3950random) = @_; >+ my ($marcrecord,$overwrite_auth,$filename,$encoding) = @_; > my $dbh = C4::Context->dbh; > > my $batch_id = GetZ3950BatchId($filename); >@@ -550,7 +542,7 @@ sub ImportBreedingAuth { > if ($breedingid && $overwrite_auth eq '1') { > ModAuthorityInBatch($breedingid, $marcrecord); > } else { >- my $import_id = AddAuthToBatch($batch_id, $imported, $marcrecord, $encoding, $z3950random); >+ my $import_id = AddAuthToBatch($batch_id, $imported, $marcrecord, $encoding); > $breedingid = $import_id; > } > $imported++; >@@ -577,25 +569,15 @@ sub Z3950SearchAuth { > > my $dbh = C4::Context->dbh; > my @id= @{$pars->{id}}; >- my $random= $pars->{random}; > my $page= $pars->{page}; > > > my $show_next = 0; > my $total_pages = 0; >- my $attr = ''; >- my $host; >- my $server; >- my $database; >- my $port; >- my $marcdata; > my @encoding; > my @results; >- my $count; >- my $record; > my @serverhost; > my @breeding_loop = (); >- > my @oConnection; > my @oResult; > my @errconn; >@@ -611,7 +593,7 @@ sub Z3950SearchAuth { > foreach my $servid (@id) { > my $sth = $dbh->prepare("select * from z3950servers where id=?"); > $sth->execute($servid); >- while ( $server = $sth->fetchrow_hashref ) { >+ while ( my $server = $sth->fetchrow_hashref ) { > $oConnection[$s] = _create_connection( $server ); > > $oResult[$s] = >@@ -619,7 +601,7 @@ sub Z3950SearchAuth { > $oConnection[$s]->search_pqf( $zquery ): > $oConnection[$s]->search(new ZOOM::Query::CQL( > _translate_query( $server, $squery ))); >- $encoding[$s] = ($server->{encoding}?$server->{encoding}:"iso-5426"); >+ $encoding[$s] = $server->{encoding} // "iso-5426"; > $servers[$s] = $server; > $s++; > } ## while fetch >@@ -636,7 +618,7 @@ sub Z3950SearchAuth { > > if ( $k != 0 ) { > $k--; >- my ($error, $errmsg, $addinfo, $diagset)= $oConnection[$k]->error_x(); >+ my ($error )= $oConnection[$k]->error_x(); #ignores errmsg, addinfo, diagset > if ($error) { > if ($error =~ m/^(10000|10007)$/ ) { > push(@errconn, {'server' => $serverhost[$k]}); >@@ -667,7 +649,7 @@ sub Z3950SearchAuth { > $heading_authtype_code = GuessAuthTypeCode($marcrecord); > $heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord }); > >- my ($notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid)= ImportBreedingAuth( $marcrecord, 2, $serverhost[$k], $encoding[$k], $random); >+ my ($notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid)= ImportBreedingAuth( $marcrecord, 2, $serverhost[$k], $encoding[$k]); > my %row_data; > $row_data{server} = $servers[$k]->{'servername'}; > $row_data{breedingid} = $breedingid; >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 99bc428701..bb3393cbc2 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -279,7 +279,7 @@ sub GetImportBatch { > =head2 AddBiblioToBatch > > my $import_record_id = AddBiblioToBatch($batch_id, $record_sequence, >- $marc_record, $encoding, $z3950random, $update_counts); >+ $marc_record, $encoding, $update_counts); > > =cut > >@@ -288,10 +288,9 @@ sub AddBiblioToBatch { > my $record_sequence = shift; > my $marc_record = shift; > my $encoding = shift; >- my $z3950random = shift; > my $update_counts = @_ ? shift : 1; > >- my $import_record_id = _create_import_record($batch_id, $record_sequence, $marc_record, 'biblio', $encoding, $z3950random, C4::Context->preference('marcflavour')); >+ my $import_record_id = _create_import_record($batch_id, $record_sequence, $marc_record, 'biblio', $encoding, C4::Context->preference('marcflavour')); > _add_biblio_fields($import_record_id, $marc_record); > _update_batch_record_counts($batch_id) if $update_counts; > return $import_record_id; >@@ -314,7 +313,7 @@ sub ModBiblioInBatch { > =head2 AddAuthToBatch > > my $import_record_id = AddAuthToBatch($batch_id, $record_sequence, >- $marc_record, $encoding, $z3950random, $update_counts, [$marc_type]); >+ $marc_record, $encoding, $update_counts, [$marc_type]); > > =cut > >@@ -323,13 +322,12 @@ sub AddAuthToBatch { > my $record_sequence = shift; > my $marc_record = shift; > my $encoding = shift; >- my $z3950random = shift; > my $update_counts = @_ ? shift : 1; > my $marc_type = shift || C4::Context->preference('marcflavour'); > > $marc_type = 'UNIMARCAUTH' if $marc_type eq 'UNIMARC'; > >- my $import_record_id = _create_import_record($batch_id, $record_sequence, $marc_record, 'auth', $encoding, $z3950random, $marc_type); >+ my $import_record_id = _create_import_record($batch_id, $record_sequence, $marc_record, 'auth', $encoding, $marc_type); > _add_auth_fields($import_record_id, $marc_record); > _update_batch_record_counts($batch_id) if $update_counts; > return $import_record_id; >@@ -1593,14 +1591,14 @@ sub RecordsFromMarcPlugin { > # internal functions > > sub _create_import_record { >- my ($batch_id, $record_sequence, $marc_record, $record_type, $encoding, $z3950random, $marc_type) = @_; >+ my ($batch_id, $record_sequence, $marc_record, $record_type, $encoding, $marc_type) = @_; > > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare("INSERT INTO import_records (import_batch_id, record_sequence, marc, marcxml, marcxml_old, >- record_type, encoding, z3950random) >- VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); >+ record_type, encoding) >+ VALUES (?, ?, ?, ?, ?, ?, ?)"); > $sth->execute($batch_id, $record_sequence, $marc_record->as_usmarc(), $marc_record->as_xml($marc_type), '', >- $record_type, $encoding, $z3950random); >+ $record_type, $encoding); > my $import_record_id = $dbh->{'mysql_insertid'}; > $sth->finish(); > return $import_record_id; >diff --git a/cataloguing/z3950_auth_search.pl b/cataloguing/z3950_auth_search.pl >index 405656de56..e4bdadced4 100755 >--- a/cataloguing/z3950_auth_search.pl >+++ b/cataloguing/z3950_auth_search.pl >@@ -88,7 +88,6 @@ if ( @id==0 ) { > } > > my $pars= { >- random => scalar $input->param('random') || rand(1000000000), > page => $page, > id => \@id, > nameany => $nameany, >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22532
:
86724
|
86725
|
87824
|
87825
| 87839 |
87840