View | Details | Raw Unified | Return to bug 19813
Collapse All | Expand All

(-)a/acqui/addorderiso2709.pl (-12 / +14 lines)
Lines 687-704 sub get_infos_syspref { Link Here
687
687
688
sub equal_number_of_fields {
688
sub equal_number_of_fields {
689
    my ($tags_list, $record) = @_;
689
    my ($tags_list, $record) = @_;
690
    my $refcount = 0;
690
    my $tag_fields_count;
691
    my $count = 0;
692
    for my $tag (@$tags_list) {
691
    for my $tag (@$tags_list) {
693
        return -1 if $count != $refcount;
692
        my @fields = $record->field($tag);
694
        $count = 0;
693
        $tag_fields_count->{$tag} = scalar @fields;
695
        for my $field ($record->field($tag)) {
694
    }
696
            $count++;
695
696
    my $tags_count;
697
    foreach my $key ( keys %$tag_fields_count ) {
698
        if ( $tag_fields_count->{$key} > 0 ) { # Having 0 of a field is ok
699
            $tags_count //= $tag_fields_count->{$key}; # Start with the count from the first occurrence
700
            return -1 if $tag_fields_count->{$key} != $tags_count; # All counts of various fields should be equal if they exist
697
        }
701
        }
698
        $refcount = $count if ($refcount == 0);
699
    }
702
    }
700
    return -1 if $count != $refcount;
703
701
    return $count;
704
    return $tags_count;
702
}
705
}
703
706
704
sub get_infos_syspref_on_item {
707
sub get_infos_syspref_on_item {
Lines 728-734 sub get_infos_syspref_on_item { Link Here
728
    @tags_list = List::MoreUtils::uniq(@tags_list);
731
    @tags_list = List::MoreUtils::uniq(@tags_list);
729
732
730
    my $tags_count = equal_number_of_fields(\@tags_list, $record);
733
    my $tags_count = equal_number_of_fields(\@tags_list, $record);
731
    # Return if the number of theses fields in the record is not the same.
734
    # Return if the number of these fields in the record is not the same.
732
    return -1 if $tags_count == -1;
735
    return -1 if $tags_count == -1;
733
736
734
    # Gather the fields
737
    # Gather the fields
Lines 749-755 sub get_infos_syspref_on_item { Link Here
749
            for my $field ( @fields ) {
752
            for my $field ( @fields ) {
750
                my ( $f, $sf ) = split /\$/, $field;
753
                my ( $f, $sf ) = split /\$/, $field;
751
                next unless $f and $sf;
754
                next unless $f and $sf;
752
                my $v = $fields_hash->{$f}[$i]->subfield( $sf );
755
                my $v = $fields_hash->{$f}[$i] ? $fields_hash->{$f}[$i]->subfield( $sf ) : undef;
753
                $r->{$field_name} = $v if (defined $v);
756
                $r->{$field_name} = $v if (defined $v);
754
                last if $yaml->{$field};
757
                last if $yaml->{$field};
755
            }
758
            }
756
- 

Return to bug 19813