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

(-)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 117-125 Returns a Koha::Patron object for this patron's guarantor Link Here
117
sub guarantor {
117
sub guarantor {
118
    my ( $self ) = @_;
118
    my ( $self ) = @_;
119
119
120
    return unless $self->guarantorid();
120
    my $guarantor;
121
    if ($self->guarantorid()) {
122
        $guarantor = Koha::Patrons->find( $self->guarantorid() );
123
    }
121
124
122
    return Koha::Patrons->find( $self->guarantorid() );
125
    return $guarantor;
123
}
126
}
124
127
125
sub image {
128
sub image {
(-)a/Koha/Subscription.pm (-1 / +1 lines)
Lines 45-51 Returns the biblio linked to this subscription as a Koha::Biblio object Link Here
45
sub biblio {
45
sub biblio {
46
    my ($self) = @_;
46
    my ($self) = @_;
47
47
48
    return scalar Koha::Biblios->find($self->biblionumber);
48
    return Koha::Biblios->find($self->biblionumber);
49
}
49
}
50
50
51
=head3 type
51
=head3 type
(-)a/acqui/booksellers.pl (-1 / +1 lines)
Lines 83-89 my $allbaskets= $query->param('allbaskets')||0; Link Here
83
my @suppliers;
83
my @suppliers;
84
84
85
if ($booksellerid) {
85
if ($booksellerid) {
86
    push @suppliers, scalar Koha::Acquisition::Booksellers->find( $booksellerid );
86
    push @suppliers, Koha::Acquisition::Booksellers->find( $booksellerid );
87
} else {
87
} else {
88
    @suppliers = Koha::Acquisition::Booksellers->search(
88
    @suppliers = Koha::Acquisition::Booksellers->search(
89
                        { name => { -like => "%$supplier%" } },
89
                        { name => { -like => "%$supplier%" } },
(-)a/acqui/uncertainprice.pl (-1 / +1 lines)
Lines 73-79 my $op = $input->param('op'); Link Here
73
my $owner = $input->param('owner') || 0 ; # flag to see only "my" orders, or everyone orders
73
my $owner = $input->param('owner') || 0 ; # flag to see only "my" orders, or everyone orders
74
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
74
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
75
75
76
$template->param( basket => scalar Koha::Acquisition::Baskets->find($basketno) );
76
$template->param( basket => Koha::Acquisition::Baskets->find($basketno) );
77
77
78
#show all orders that have uncertain price for the bookseller
78
#show all orders that have uncertain price for the bookseller
79
my $pendingorders = SearchOrders({
79
my $pendingorders = SearchOrders({
(-)a/members/memberentry.pl (-1 / +1 lines)
Lines 780-786 $template->param( csrf_token => Link Here
780
780
781
# HouseboundModule data
781
# HouseboundModule data
782
$template->param(
782
$template->param(
783
    housebound_role  => scalar Koha::Patron::HouseboundRoles->find($borrowernumber),
783
    housebound_role  => Koha::Patron::HouseboundRoles->find($borrowernumber),
784
);
784
);
785
785
786
if(defined($data{'flags'})){
786
if(defined($data{'flags'})){
(-)a/members/pay.pl (-2 / +2 lines)
Lines 103-109 if ($writeoff_all) { Link Here
103
    Koha::Account->new( { patron_id => $borrowernumber } )->pay(
103
    Koha::Account->new( { patron_id => $borrowernumber } )->pay(
104
        {
104
        {
105
            amount     => $amount,
105
            amount     => $amount,
106
            lines      => [ scalar Koha::Account::Lines->find($accountlines_id) ],
106
            lines      => [ Koha::Account::Lines->find($accountlines_id) ],
107
            type       => 'writeoff',
107
            type       => 'writeoff',
108
            note       => $payment_note,
108
            note       => $payment_note,
109
            library_id => $branch,
109
            library_id => $branch,
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
                    library_id => $branch,
220
                    library_id => $branch,
(-)a/opac/opac-memberentry.pl (-1 / +1 lines)
Lines 305-311 elsif ( $action eq 'edit' ) { #Display logged in borrower's data Link Here
305
305
306
    $template->param(
306
    $template->param(
307
        borrower  => $borrower,
307
        borrower  => $borrower,
308
        guarantor => scalar Koha::Patrons->find($borrowernumber)->guarantor(),
308
        guarantor => Koha::Patrons->find($borrowernumber)->guarantor(),
309
        hidden => GetHiddenFields( $mandatory, 'modification' ),
309
        hidden => GetHiddenFields( $mandatory, 'modification' ),
310
        csrf_token => Koha::Token->new->generate_csrf({
310
        csrf_token => Koha::Token->new->generate_csrf({
311
            session_id => scalar $cgi->cookie('CGISESSID'),
311
            session_id => scalar $cgi->cookie('CGISESSID'),
(-)a/opac/opac-user.pl (-1 / +1 lines)
Lines 345-351 if ( C4::Context->preference('AllowPatronToSetCheckoutsVisibilityForGuarantor' Link Here
345
}
345
}
346
346
347
$template->param(
347
$template->param(
348
    borrower                 => scalar Koha::Patrons->find($borrowernumber),
348
    borrower                 => Koha::Patrons->find($borrowernumber),
349
    patron_messages          => $patron_messages,
349
    patron_messages          => $patron_messages,
350
    opacnote                 => $borr->{opacnote},
350
    opacnote                 => $borr->{opacnote},
351
    patronupdate             => $patronupdate,
351
    patronupdate             => $patronupdate,
(-)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