|
Lines 103-108
use Koha::Holds;
Link Here
|
| 103 |
use Koha::ItemTypes; |
103 |
use Koha::ItemTypes; |
| 104 |
use Koha::Plugins; |
104 |
use Koha::Plugins; |
| 105 |
use Koha::SearchEngine; |
105 |
use Koha::SearchEngine; |
|
|
106 |
use Koha::SearchEngine::Indexer; |
| 106 |
use Koha::Libraries; |
107 |
use Koha::Libraries; |
| 107 |
use Koha::Util::MARC; |
108 |
use Koha::Util::MARC; |
| 108 |
|
109 |
|
|
Lines 366-372
C<$error> : undef unless an error occurs
Link Here
|
| 366 |
=cut |
367 |
=cut |
| 367 |
|
368 |
|
| 368 |
sub DelBiblio { |
369 |
sub DelBiblio { |
| 369 |
my ($biblionumber) = @_; |
370 |
my ($biblionumber, $params) = @_; |
| 370 |
|
371 |
|
| 371 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
372 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
| 372 |
return unless $biblio; # Should we throw an exception instead? |
373 |
return unless $biblio; # Should we throw an exception instead? |
|
Lines 391-401
sub DelBiblio {
Link Here
|
| 391 |
$hold->cancel; |
392 |
$hold->cancel; |
| 392 |
} |
393 |
} |
| 393 |
|
394 |
|
| 394 |
# Delete in Zebra. Be careful NOT to move this line after _koha_delete_biblio |
395 |
unless ( $params->{skip_record_index} ){ |
| 395 |
# for at least 2 reasons : |
396 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
| 396 |
# - if something goes wrong, the biblio may be deleted from Koha but not from zebra |
397 |
$indexer->index_records( $biblionumber, "recordDelete", "biblioserver" ); |
| 397 |
# and we would have no way to remove it (except manually in zebra, but I bet it would be very hard to handle the problem) |
398 |
} |
| 398 |
ModZebra( $biblionumber, "recordDelete", "biblioserver" ); |
|
|
| 399 |
|
399 |
|
| 400 |
# delete biblioitems and items from Koha tables and save in deletedbiblioitems,deleteditems |
400 |
# delete biblioitems and items from Koha tables and save in deletedbiblioitems,deleteditems |
| 401 |
$sth = $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); |
401 |
$sth = $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); |
|
Lines 2489-2538
sub CountItemsIssued {
Link Here
|
| 2489 |
|
2489 |
|
| 2490 |
=head2 ModZebra |
2490 |
=head2 ModZebra |
| 2491 |
|
2491 |
|
| 2492 |
ModZebra( $biblionumber, $op, $server, $record ); |
2492 |
ModZebra( $record_number, $op, $server, $record ); |
| 2493 |
|
2493 |
|
| 2494 |
$biblionumber is the biblionumber we want to index |
2494 |
$record_number is the authid or biblionumber we want to index |
| 2495 |
|
2495 |
|
| 2496 |
$op is specialUpdate or recordDelete, and is used to know what we want to do |
2496 |
$op is the operation: specialUpdate or recordDelete |
| 2497 |
|
2497 |
|
| 2498 |
$server is the server that we want to update |
2498 |
$server is authorityserver or biblioserver |
| 2499 |
|
|
|
| 2500 |
$record is the updated MARC record. If it's not supplied |
| 2501 |
and is needed it will be loaded from the database. |
| 2502 |
|
2499 |
|
| 2503 |
=cut |
2500 |
=cut |
| 2504 |
|
2501 |
|
| 2505 |
sub ModZebra { |
2502 |
sub ModZebra { |
| 2506 |
###Accepts a $server variable thus we can use it for biblios authorities or other zebra dbs |
2503 |
my ( $record_number, $op, $server ) = @_; |
| 2507 |
my ( $biblionumber, $op, $server, $record ) = @_; |
2504 |
$debug && warn "ModZebra: updates requested for: $record_number $op $server\n"; |
| 2508 |
$debug && warn "ModZebra: update requested for: $biblionumber $op $server\n"; |
|
|
| 2509 |
if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) { |
| 2510 |
|
| 2511 |
# TODO abstract to a standard API that'll work for whatever |
| 2512 |
require Koha::SearchEngine::Elasticsearch::Indexer; |
| 2513 |
my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new( |
| 2514 |
{ |
| 2515 |
index => $server eq 'biblioserver' |
| 2516 |
? $Koha::SearchEngine::BIBLIOS_INDEX |
| 2517 |
: $Koha::SearchEngine::AUTHORITIES_INDEX |
| 2518 |
} |
| 2519 |
); |
| 2520 |
if ( $op eq 'specialUpdate' ) { |
| 2521 |
unless ($record) { |
| 2522 |
$record = GetMarcBiblio({ |
| 2523 |
biblionumber => $biblionumber, |
| 2524 |
embed_items => 1 }); |
| 2525 |
} |
| 2526 |
$indexer->update_index_background( [$biblionumber], [$record] ); |
| 2527 |
} |
| 2528 |
elsif ( $op eq 'recordDelete' ) { |
| 2529 |
$indexer->delete_index_background( [$biblionumber] ); |
| 2530 |
} |
| 2531 |
else { |
| 2532 |
croak "ModZebra called with unknown operation: $op"; |
| 2533 |
} |
| 2534 |
} |
| 2535 |
|
| 2536 |
my $dbh = C4::Context->dbh; |
2505 |
my $dbh = C4::Context->dbh; |
| 2537 |
|
2506 |
|
| 2538 |
# true ModZebra commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates |
2507 |
# true ModZebra commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates |
|
Lines 2545-2561
sub ModZebra {
Link Here
|
| 2545 |
AND operation = ? |
2514 |
AND operation = ? |
| 2546 |
AND done = 0"; |
2515 |
AND done = 0"; |
| 2547 |
my $check_sth = $dbh->prepare_cached($check_sql); |
2516 |
my $check_sth = $dbh->prepare_cached($check_sql); |
| 2548 |
$check_sth->execute( $server, $biblionumber, $op ); |
2517 |
$check_sth->execute( $server, $record_number, $op ); |
| 2549 |
my ($count) = $check_sth->fetchrow_array; |
2518 |
my ($count) = $check_sth->fetchrow_array; |
| 2550 |
$check_sth->finish(); |
2519 |
$check_sth->finish(); |
| 2551 |
if ( $count == 0 ) { |
2520 |
if ( $count == 0 ) { |
| 2552 |
my $sth = $dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,server,operation) VALUES(?,?,?)"); |
2521 |
my $sth = $dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,server,operation) VALUES(?,?,?)"); |
| 2553 |
$sth->execute( $biblionumber, $server, $op ); |
2522 |
$sth->execute( $record_number, $server, $op ); |
| 2554 |
$sth->finish; |
2523 |
$sth->finish; |
| 2555 |
} |
2524 |
} |
| 2556 |
} |
2525 |
} |
| 2557 |
|
2526 |
|
| 2558 |
|
|
|
| 2559 |
=head2 EmbedItemsInMarcBiblio |
2527 |
=head2 EmbedItemsInMarcBiblio |
| 2560 |
|
2528 |
|
| 2561 |
EmbedItemsInMarcBiblio({ |
2529 |
EmbedItemsInMarcBiblio({ |
|
Lines 3147-3153
sub ModBiblioMarc {
Link Here
|
| 3147 |
$m_rs->metadata( $record->as_xml_record($encoding) ); |
3115 |
$m_rs->metadata( $record->as_xml_record($encoding) ); |
| 3148 |
$m_rs->store; |
3116 |
$m_rs->store; |
| 3149 |
|
3117 |
|
| 3150 |
ModZebra( $biblionumber, "specialUpdate", "biblioserver" ); |
3118 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
|
|
3119 |
$indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" ); |
| 3151 |
|
3120 |
|
| 3152 |
return $biblionumber; |
3121 |
return $biblionumber; |
| 3153 |
} |
3122 |
} |