|
Lines 680-685
sub get_raw_marc_record {
Link Here
|
| 680 |
warn "error retrieving biblio $record_number"; |
680 |
warn "error retrieving biblio $record_number"; |
| 681 |
return; |
681 |
return; |
| 682 |
} |
682 |
} |
|
|
683 |
_protectZebraFromTooManyItems($marc); |
| 683 |
} |
684 |
} |
| 684 |
} else { |
685 |
} else { |
| 685 |
eval { $marc = GetAuthority($record_number); }; |
686 |
eval { $marc = GetAuthority($record_number); }; |
|
Lines 788-793
sub do_indexing {
Link Here
|
| 788 |
|
789 |
|
| 789 |
} |
790 |
} |
| 790 |
|
791 |
|
|
|
792 |
=head2 _protectZebraFromTooManyItems |
| 793 |
|
| 794 |
_protectZebraFromTooManyItems($marcRecord); |
| 795 |
|
| 796 |
Finds the repeatable items-field inside the given MARC::Record and drops all but the first handful of new items. |
| 797 |
Zebra cannot index a record if it is over 1MB in size, and this limit can be reached by injecting the Item-data |
| 798 |
to the MARC-Record. |
| 799 |
For ex. serials have one MARC record with possibly thousands of items. |
| 800 |
|
| 801 |
=cut |
| 802 |
|
| 803 |
my ($itemsBarcodeFieldCode, $itemsBarcodeSubfieldCode, $serialFieldCode, $serialSubfieldCode); |
| 804 |
sub _protectZebraFromTooManyItems { |
| 805 |
use Modern::Perl; #WTF this script doesn't even have warnings on. Goddamn |
| 806 |
my ($marc) = @_; |
| 807 |
|
| 808 |
my ($itemsBarcodeFieldCode, $itemsBarcodeSubfieldCode) = C4::Biblio::GetMarcFromKohaField('items.barcode','') unless $itemsBarcodeFieldCode; |
| 809 |
my ($serialFieldCode, $serialSubfieldCode) = C4::Biblio::GetMarcFromKohaField('biblio.serial','') unless $serialFieldCode; |
| 810 |
if ($marc->subfield($serialFieldCode, $serialSubfieldCode)) { #Is a serial, has a subscription basically |
| 811 |
my $maxIndexedItems = 500; #in MARC mode we should be able to create a ISO-format MARC21 record with this many items. Record size limit is 99999 characters. |
| 812 |
my @fields = reverse $marc->field($itemsBarcodeFieldCode); #field actually returns fields |
| 813 |
my $fCnt = scalar(@fields)-1; |
| 814 |
|
| 815 |
if (scalar(@fields) > $maxIndexedItems) { |
| 816 |
my @deletable = @fields[$maxIndexedItems..$fCnt]; |
| 817 |
$marc->delete_fields(@deletable); #Trim the rest of the items. |
| 818 |
} |
| 819 |
} |
| 820 |
} |
| 821 |
|
| 791 |
sub _flock { |
822 |
sub _flock { |
| 792 |
# test if flock is present; if so, use it; if not, return true |
823 |
# test if flock is present; if so, use it; if not, return true |
| 793 |
# op refers to the official flock operations including LOCK_EX, |
824 |
# op refers to the official flock operations including LOCK_EX, |
| 794 |
- |
|
|