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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 677-683 sub CanBookBeIssued { Link Here
677
677
678
    # MANDATORY CHECKS - unless item exists, nothing else matters
678
    # MANDATORY CHECKS - unless item exists, nothing else matters
679
    unless ( $item->{barcode} ) {
679
    unless ( $item->{barcode} ) {
680
        Koha::Statistics->invalid_item( { item => $barcode } );
680
        Koha::Statistics->log_invalid_item( { item => $barcode } );
681
        $issuingimpossible{UNKNOWN_BARCODE} = 1;
681
        $issuingimpossible{UNKNOWN_BARCODE} = 1;
682
    }
682
    }
683
	return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible;
683
	return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible;
Lines 1803-1809 sub AddReturn { Link Here
1803
    # get information on item
1803
    # get information on item
1804
    my $item = GetItem( undef, $barcode );
1804
    my $item = GetItem( undef, $barcode );
1805
    unless ($item) {
1805
    unless ($item) {
1806
        Koha::Statistics->invalid_item( { item => $barcode } );
1806
        Koha::Statistics->log_invalid_item( { item => $barcode } );
1807
        return ( 0, { BadBarcode => $barcode } );    # no barcode means no item or borrower.  bail out.
1807
        return ( 0, { BadBarcode => $barcode } );    # no barcode means no item or borrower.  bail out.
1808
    }
1808
    }
1809
1809
(-)a/Koha/Statistics.pm (-9 / +9 lines)
Lines 35-47 Koha::Statistics - Koha Statistic Object set class Link Here
35
35
36
=head2 Class Methods
36
=head2 Class Methods
37
37
38
=head3 invalid_patron
38
=head3 log_invalid_patron
39
39
40
Koha::Statistics->invalid_patron( { patron => $cardnumber } );
40
Koha::Statistics->log_invalid_patron( { patron => $cardnumber } );
41
41
42
=cut
42
=cut
43
43
44
sub invalid_patron {
44
sub log_invalid_patron {
45
    return unless C4::Context->preference('LogInvalidPatrons');
45
    return unless C4::Context->preference('LogInvalidPatrons');
46
46
47
    my ( $class, $params ) = @_;
47
    my ( $class, $params ) = @_;
Lines 49-55 sub invalid_patron { Link Here
49
    my $patron = $params->{patron};
49
    my $patron = $params->{patron};
50
    croak('Invalid patron passed in!') unless $patron;
50
    croak('Invalid patron passed in!') unless $patron;
51
51
52
    return $class->_invalid_value(
52
    return $class->_log_invalid_value(
53
        {
53
        {
54
            type  => 'patron',
54
            type  => 'patron',
55
            value => $patron
55
            value => $patron
Lines 57-69 sub invalid_patron { Link Here
57
    );
57
    );
58
}
58
}
59
59
60
=head3 invalid_item
60
=head3 log_invalid_item
61
61
62
Koha::Statistics->invalid_item( { item => $barcode } );
62
Koha::Statistics->log_invalid_item( { item => $barcode } );
63
63
64
=cut
64
=cut
65
65
66
sub invalid_item {
66
sub log_invalid_item {
67
    return unless C4::Context->preference('LogInvalidItems');
67
    return unless C4::Context->preference('LogInvalidItems');
68
68
69
    my ( $class, $params ) = @_;
69
    my ( $class, $params ) = @_;
Lines 71-77 sub invalid_item { Link Here
71
    my $item = $params->{item};
71
    my $item = $params->{item};
72
    croak('Invalid item passed in!') unless $item;
72
    croak('Invalid item passed in!') unless $item;
73
73
74
    return $class->_invalid_value(
74
    return $class->_log_invalid_value(
75
        {
75
        {
76
            type  => 'item',
76
            type  => 'item',
77
            value => $item
77
            value => $item
Lines 85-91 Koha::Statistics->invalid_value( { type => 'patron', value => $patron } ); Link Here
85
85
86
=cut
86
=cut
87
87
88
sub _invalid_value {
88
sub _log_invalid_value {
89
    my ( $class, $params ) = @_;
89
    my ( $class, $params ) = @_;
90
90
91
    my $type  = $params->{type};
91
    my $type  = $params->{type};
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 266-272 if ($findborrower) { Link Here
266
        } elsif ( @$borrowers ) {
266
        } elsif ( @$borrowers ) {
267
            $template->param( borrowers => $borrowers );
267
            $template->param( borrowers => $borrowers );
268
        } else {
268
        } else {
269
            Koha::Statistics->invalid_patron( { patron => $findborrower } );
269
            Koha::Statistics->log_invalid_patron( { patron => $findborrower } );
270
            $query->param( 'findborrower', '' );
270
            $query->param( 'findborrower', '' );
271
            $message = "'$findborrower'";
271
            $message = "'$findborrower'";
272
        }
272
        }
(-)a/t/db_dependent/Stats.t (-7 / +6 lines)
Lines 191-218 $context->mock( Link Here
191
        };
191
        };
192
    }
192
    }
193
);
193
);
194
# Test Koha::Statistic->invalid_patron
194
# Test Koha::Statistic->log_invalid_patron
195
$dbh->do(q{DELETE FROM statistics});
195
$dbh->do(q{DELETE FROM statistics});
196
t::lib::Mocks::mock_preference( "LogInvalidPatrons", 0 );
196
t::lib::Mocks::mock_preference( "LogInvalidPatrons", 0 );
197
Koha::Statistics->invalid_patron( { patron => 'InvalidCardnumber' } );
197
Koha::Statistics->log_invalid_patron( { patron => 'InvalidCardnumber' } );
198
is( Koha::Statistics->search()->count(), 0, 'No stat line added if system preference LogInvalidPatrons is disabled' );
198
is( Koha::Statistics->search()->count(), 0, 'No stat line added if system preference LogInvalidPatrons is disabled' );
199
199
200
t::lib::Mocks::mock_preference( "LogInvalidPatrons", 1 );
200
t::lib::Mocks::mock_preference( "LogInvalidPatrons", 1 );
201
Koha::Statistics->invalid_patron( { patron => 'InvalidCardnumber' } );
201
Koha::Statistics->log_invalid_patron( { patron => 'InvalidCardnumber' } );
202
my $stat = Koha::Statistics->search()->next();
202
my $stat = Koha::Statistics->search()->next();
203
is( $stat->type, 'invalid_patron', 'Type set to invalid_patron' );
203
is( $stat->type, 'invalid_patron', 'Type set to invalid_patron' );
204
is( $stat->associatedborrower, '-1', 'Associated library id set correctly' );
204
is( $stat->associatedborrower, '-1', 'Associated library id set correctly' );
205
is( $stat->other, 'InvalidCardnumber', 'Invalid cardnumber is set correctly' );
205
is( $stat->other, 'InvalidCardnumber', 'Invalid cardnumber is set correctly' );
206
is( $stat->branch, $branchcode, 'Branchcode is set correctly' );
206
is( $stat->branch, $branchcode, 'Branchcode is set correctly' );
207
207
208
# Test Koha::Statistic->invalid_item
208
# Test Koha::Statistic->log_invalid_item
209
$dbh->do(q{DELETE FROM statistics});
209
$dbh->do(q{DELETE FROM statistics});
210
t::lib::Mocks::mock_preference( "LogInvalidItems", 0 );
210
t::lib::Mocks::mock_preference( "LogInvalidItems", 0 );
211
Koha::Statistics->invalid_item( { item => 'InvalidBarcode' } );
211
Koha::Statistics->log_invalid_item( { item => 'InvalidBarcode' } );
212
is( Koha::Statistics->search()->count(), 0, 'No stat line added if system preference LogInvalidItems is disabled' );
212
is( Koha::Statistics->search()->count(), 0, 'No stat line added if system preference LogInvalidItems is disabled' );
213
213
214
t::lib::Mocks::mock_preference( "LogInvalidItems", 1 );
214
t::lib::Mocks::mock_preference( "LogInvalidItems", 1 );
215
Koha::Statistics->invalid_item( { item => 'InvalidBarcode' } );
215
Koha::Statistics->log_invalid_item( { item => 'InvalidBarcode' } );
216
$stat = Koha::Statistics->search()->next();
216
$stat = Koha::Statistics->search()->next();
217
is( $stat->type, 'invalid_item', 'Type set to invalid_item' );
217
is( $stat->type, 'invalid_item', 'Type set to invalid_item' );
218
is( $stat->associatedborrower, '-1', 'Associated library id set correctly' );
218
is( $stat->associatedborrower, '-1', 'Associated library id set correctly' );
219
- 

Return to bug 16117