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

(-)a/C4/Reserves.pm (-1 / +1 lines)
Lines 800-806 sub CheckReserves { Link Here
800
                    next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $patron->branchcode));
800
                    next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $patron->branchcode));
801
                    my $hold_fulfillment_policy = $branchitemrule->{hold_fulfillment_policy};
801
                    my $hold_fulfillment_policy = $branchitemrule->{hold_fulfillment_policy};
802
                    next if ( ($branchitemrule->{hold_fulfillment_policy} ne 'any') && ($res->{branchcode} ne $item->$hold_fulfillment_policy) );
802
                    next if ( ($branchitemrule->{hold_fulfillment_policy} ne 'any') && ($res->{branchcode} ne $item->$hold_fulfillment_policy) );
803
                    next unless $item->can_be_transferred( { to => scalar Koha::Libraries->find( $res->{branchcode} ) } );
803
                    next unless $item->can_be_transferred( { to => Koha::Libraries->find( $res->{branchcode} ) } );
804
                    $priority = $res->{'priority'};
804
                    $priority = $res->{'priority'};
805
                    $highest  = $res;
805
                    $highest  = $res;
806
                    last if $local_hold_match;
806
                    last if $local_hold_match;
(-)a/C4/SIP/ILS/Transaction/Hold.pm (-1 / +1 lines)
Lines 60-66 sub do_hold { Link Here
60
        $self->ok(0);
60
        $self->ok(0);
61
        return $self;
61
        return $self;
62
    }
62
    }
63
    unless ( $item->can_be_transferred( { to => scalar Koha::Libraries->find( $branch ) } ) ) {
63
    unless ( $item->can_be_transferred( { to => Koha::Libraries->find( $branch ) } ) ) {
64
        $self->screen_msg('Item cannot be transferred.');
64
        $self->screen_msg('Item cannot be transferred.');
65
        $self->ok(0);
65
        $self->ok(0);
66
        return $self;
66
        return $self;
(-)a/Koha/Club.pm (-2 / +2 lines)
Lines 48-54 sub club_template { Link Here
48
48
49
    return unless $self->club_template_id();
49
    return unless $self->club_template_id();
50
50
51
    return scalar Koha::Club::Templates->find( $self->club_template_id() );
51
    return Koha::Club::Templates->find( $self->club_template_id() );
52
}
52
}
53
53
54
=head3 club_fields
54
=head3 club_fields
Lines 84-90 sub branch { Link Here
84
84
85
    return unless $self->branchcode();
85
    return unless $self->branchcode();
86
86
87
    return scalar Koha::Libraries->find( $self->branchcode() );
87
    return Koha::Libraries->find( $self->branchcode() );
88
}
88
}
89
89
90
=head3 type
90
=head3 type
(-)a/Koha/Club/Enrollment.pm (-2 / +2 lines)
Lines 59-65 sub cancel { Link Here
59
59
60
sub club {
60
sub club {
61
    my ( $self ) = @_;
61
    my ( $self ) = @_;
62
    return scalar Koha::Clubs->find( $self->club_id() );
62
    return Koha::Clubs->find( $self->club_id() );
63
}
63
}
64
64
65
=head3 patron
65
=head3 patron
Lines 68-74 sub club { Link Here
68
68
69
sub patron {
69
sub patron {
70
    my ( $self ) = @_;
70
    my ( $self ) = @_;
71
    return scalar Koha::Patrons->find( $self->borrowernumber() );
71
    return Koha::Patrons->find( $self->borrowernumber() );
72
}
72
}
73
73
74
=head3 type
74
=head3 type
(-)a/Koha/Club/Field.pm (-1 / +1 lines)
Lines 46-52 Represents the value set at creation time for a Koha::Club::Template::Field Link Here
46
sub club_template_field {
46
sub club_template_field {
47
    my ( $self ) = @_;
47
    my ( $self ) = @_;
48
48
49
    return scalar Koha::Club::Template::Fields->find( $self->club_template_field_id );
49
    return Koha::Club::Template::Fields->find( $self->club_template_field_id );
50
}
50
}
51
51
52
=head3 type
52
=head3 type
(-)a/Koha/Objects.pm (-9 / +9 lines)
Lines 85-99 my $object = Koha::Objects->find( $idpart1, $idpart2, $attrs ); # composite PK Link Here
85
sub find {
85
sub find {
86
    my ( $self, @pars ) = @_;
86
    my ( $self, @pars ) = @_;
87
87
88
    croak 'Cannot use "->find" in list context' if wantarray;
88
    my $object;
89
89
90
    return if !@pars || none { defined($_) } @pars;
90
    @pars = grep { defined } @pars;
91
91
    if (@pars) {
92
    my $result = $self->_resultset()->find( @pars );
92
        my $result = $self->_resultset()->find(@pars);
93
93
        if ($result) {
94
    return unless $result;
94
            $object = $self->object_class()->_new_from_dbic($result);
95
95
        }
96
    my $object = $self->object_class()->_new_from_dbic( $result );
96
    }
97
97
98
    return $object;
98
    return $object;
99
}
99
}
(-)a/Koha/Patron.pm (-2 / +5 lines)
Lines 374-382 Returns a Koha::Patron object for this patron's guarantor Link Here
374
sub guarantor {
374
sub guarantor {
375
    my ( $self ) = @_;
375
    my ( $self ) = @_;
376
376
377
    return unless $self->guarantorid();
377
    my $guarantor;
378
    if ($self->guarantorid()) {
379
        $guarantor = Koha::Patrons->find( $self->guarantorid() );
380
    }
378
381
379
    return Koha::Patrons->find( $self->guarantorid() );
382
    return $guarantor;
380
}
383
}
381
384
382
sub image {
385
sub image {
(-)a/Koha/Subscription.pm (-2 / +2 lines)
Lines 51-57 Returns the biblio linked to this subscription as a Koha::Biblio object Link Here
51
sub biblio {
51
sub biblio {
52
    my ($self) = @_;
52
    my ($self) = @_;
53
53
54
    return scalar Koha::Biblios->find($self->biblionumber);
54
    return Koha::Biblios->find($self->biblionumber);
55
}
55
}
56
56
57
=head3 vendor
57
=head3 vendor
Lines 62-68 Returns the vendor/supplier linked to this subscription as a Koha::Acquisition:: Link Here
62
62
63
sub vendor {
63
sub vendor {
64
    my ($self) = @_;
64
    my ($self) = @_;
65
    return scalar Koha::Acquisition::Booksellers->find($self->aqbooksellerid);
65
    return Koha::Acquisition::Booksellers->find($self->aqbooksellerid);
66
}
66
}
67
67
68
=head3 subscribers
68
=head3 subscribers
(-)a/acqui/booksellers.pl (-1 / +1 lines)
Lines 82-88 my $allbaskets= $query->param('allbaskets')||0; Link Here
82
my @suppliers;
82
my @suppliers;
83
83
84
if ($booksellerid) {
84
if ($booksellerid) {
85
    push @suppliers, scalar Koha::Acquisition::Booksellers->find( $booksellerid );
85
    push @suppliers, Koha::Acquisition::Booksellers->find( $booksellerid );
86
} else {
86
} else {
87
    @suppliers = Koha::Acquisition::Booksellers->search(
87
    @suppliers = Koha::Acquisition::Booksellers->search(
88
                        { name => { -like => "%$supplier%" } },
88
                        { name => { -like => "%$supplier%" } },
(-)a/acqui/uncertainprice.pl (-1 / +1 lines)
Lines 72-78 my $op = $input->param('op'); Link Here
72
my $owner = $input->param('owner') || 0 ; # flag to see only "my" orders, or everyone orders
72
my $owner = $input->param('owner') || 0 ; # flag to see only "my" orders, or everyone orders
73
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
73
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
74
74
75
$template->param( basket => scalar Koha::Acquisition::Baskets->find($basketno) );
75
$template->param( basket => Koha::Acquisition::Baskets->find($basketno) );
76
76
77
#show all orders that have uncertain price for the bookseller
77
#show all orders that have uncertain price for the bookseller
78
my $pendingorders = SearchOrders({
78
my $pendingorders = SearchOrders({
(-)a/cataloguing/moveitem.pl (-1 / +1 lines)
Lines 79-85 if ( $barcode && $biblionumber ) { Link Here
79
        if ($moveresult) {
79
        if ($moveresult) {
80
            $template->param(
80
            $template->param(
81
                success => 1,
81
                success => 1,
82
                from_biblio => scalar Koha::Biblios->find($frombiblionumber),
82
                from_biblio => Koha::Biblios->find($frombiblionumber),
83
            );
83
            );
84
        }
84
        }
85
        else {
85
        else {
(-)a/circ/overdue.pl (-1 / +1 lines)
Lines 299-305 if ($noreport) { Link Here
299
        }
299
        }
300
300
301
        push @overduedata, {
301
        push @overduedata, {
302
            patron                 => scalar Koha::Patrons->find( $data->{borrowernumber} ),
302
            patron                 => Koha::Patrons->find( $data->{borrowernumber} ),
303
            duedate                => $data->{date_due},
303
            duedate                => $data->{date_due},
304
            borrowernumber         => $data->{borrowernumber},
304
            borrowernumber         => $data->{borrowernumber},
305
            cardnumber             => $data->{cardnumber},
305
            cardnumber             => $data->{cardnumber},
(-)a/members/memberentry.pl (-1 / +1 lines)
Lines 800-806 $template->param( csrf_token => Link Here
800
800
801
# HouseboundModule data
801
# HouseboundModule data
802
$template->param(
802
$template->param(
803
    housebound_role  => scalar Koha::Patron::HouseboundRoles->find($borrowernumber),
803
    housebound_role  => Koha::Patron::HouseboundRoles->find($borrowernumber),
804
);
804
);
805
805
806
if(defined($data{'flags'})){
806
if(defined($data{'flags'})){
(-)a/members/pay.pl (-2 / +2 lines)
Lines 110-116 elsif ( $input->param('confirm_writeoff') ) { Link Here
110
        Koha::Account->new( { patron_id => $borrowernumber } )->pay(
110
        Koha::Account->new( { patron_id => $borrowernumber } )->pay(
111
            {
111
            {
112
                amount     => $amount,
112
                amount     => $amount,
113
                lines      => [ scalar Koha::Account::Lines->find($accountlines_id) ],
113
                lines      => [ Koha::Account::Lines->find($accountlines_id) ],
114
                type       => 'writeoff',
114
                type       => 'writeoff',
115
                note       => $payment_note,
115
                note       => $payment_note,
116
                interface  => C4::Context->interface,
116
                interface  => C4::Context->interface,
Lines 214-220 sub writeoff_all { Link Here
214
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
214
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
215
                {
215
                {
216
                    amount => $amount,
216
                    amount => $amount,
217
                    lines  => [ scalar Koha::Account::Lines->find($accountlines_id) ],
217
                    lines  => [ Koha::Account::Lines->find($accountlines_id) ],
218
                    type   => 'writeoff',
218
                    type   => 'writeoff',
219
                    note   => $payment_note,
219
                    note   => $payment_note,
220
                    interface  => C4::Context->interface,
220
                    interface  => C4::Context->interface,
(-)a/opac/opac-memberentry.pl (-1 / +1 lines)
Lines 312-318 elsif ( $action eq 'edit' ) { #Display logged in borrower's data Link Here
312
312
313
    $template->param(
313
    $template->param(
314
        borrower  => $borrower,
314
        borrower  => $borrower,
315
        guarantor => scalar Koha::Patrons->find($borrowernumber)->guarantor(),
315
        guarantor => Koha::Patrons->find($borrowernumber)->guarantor(),
316
        hidden => GetHiddenFields( $mandatory, 'edit' ),
316
        hidden => GetHiddenFields( $mandatory, 'edit' ),
317
        csrf_token => Koha::Token->new->generate_csrf({
317
        csrf_token => Koha::Token->new->generate_csrf({
318
            session_id => scalar $cgi->cookie('CGISESSID'),
318
            session_id => scalar $cgi->cookie('CGISESSID'),
(-)a/t/db_dependent/Koha/Objects.t (-4 / +10 lines)
Lines 46-58 my $borrowernumber_exists = grep { /^borrowernumber$/ } @columns; Link Here
46
is( $borrowernumber_exists, 1, 'Koha::Objects->columns should return the table columns' );
46
is( $borrowernumber_exists, 1, 'Koha::Objects->columns should return the table columns' );
47
47
48
subtest 'find' => sub {
48
subtest 'find' => sub {
49
    plan tests => 4;
49
    plan tests => 6;
50
    my $patron = $builder->build({source => 'Borrower'});
50
    my $patron = $builder->build({source => 'Borrower'});
51
    my $patron_object = Koha::Patrons->find( $patron->{borrowernumber} );
51
    my $patron_object = Koha::Patrons->find( $patron->{borrowernumber} );
52
    is( $patron_object->borrowernumber, $patron->{borrowernumber}, '->find should return the correct object' );
52
    is( $patron_object->borrowernumber, $patron->{borrowernumber}, '->find should return the correct object' );
53
53
54
    eval { my @patrons = Koha::Patrons->find( $patron->{borrowernumber} ); };
54
    my @patrons = Koha::Patrons->find( $patron->{borrowernumber} );
55
    like( $@, qr|^Cannot use "->find" in list context|, "->find should not be called in list context to avoid side-effects" );
55
    is(scalar @patrons, 1, '->find in list context returns a value');
56
    is($patrons[0]->borrowernumber, $patron->{borrowernumber}, '->find in list context returns the same value as in scalar context');
57
58
    my $patrons = {
59
        foo => Koha::Patrons->find('foo'),
60
        bar => 'baz',
61
    };
62
    is ($patrons->{foo}, undef, '->find in list context returns undef when no record is found');
56
63
57
    # Test sending undef to find; should not generate a warning
64
    # Test sending undef to find; should not generate a warning
58
    warning_is { $patron = Koha::Patrons->find( undef ); }
65
    warning_is { $patron = Koha::Patrons->find( undef ); }
59
- 

Return to bug 19809