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 118-126 Returns a Koha::Patron object for this patron's guarantor Link Here
118
sub guarantor {
118
sub guarantor {
119
    my ( $self ) = @_;
119
    my ( $self ) = @_;
120
120
121
    return unless $self->guarantorid();
121
    my $guarantor;
122
    if ($self->guarantorid()) {
123
        $guarantor = Koha::Patrons->find( $self->guarantorid() );
124
    }
122
125
123
    return Koha::Patrons->find( $self->guarantorid() );
126
    return $guarantor;
124
}
127
}
125
128
126
sub image {
129
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 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/members/memberentry.pl (-1 / +1 lines)
Lines 782-788 $template->param( csrf_token => Link Here
782
782
783
# HouseboundModule data
783
# HouseboundModule data
784
$template->param(
784
$template->param(
785
    housebound_role  => scalar Koha::Patron::HouseboundRoles->find($borrowernumber),
785
    housebound_role  => Koha::Patron::HouseboundRoles->find($borrowernumber),
786
);
786
);
787
787
788
if(defined($data{'flags'})){
788
if(defined($data{'flags'})){
(-)a/members/pay.pl (-2 / +2 lines)
Lines 96-102 if ($writeoff_all) { Link Here
96
    Koha::Account->new( { patron_id => $borrowernumber } )->pay(
96
    Koha::Account->new( { patron_id => $borrowernumber } )->pay(
97
        {
97
        {
98
            amount     => $amount,
98
            amount     => $amount,
99
            lines      => [ scalar Koha::Account::Lines->find($accountlines_id) ],
99
            lines      => [ Koha::Account::Lines->find($accountlines_id) ],
100
            type       => 'writeoff',
100
            type       => 'writeoff',
101
            note       => $payment_note,
101
            note       => $payment_note,
102
            library_id => $branch,
102
            library_id => $branch,
Lines 202-208 sub writeoff_all { Link Here
202
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
202
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
203
                {
203
                {
204
                    amount => $amount,
204
                    amount => $amount,
205
                    lines  => [ scalar Koha::Account::Lines->find($accountlines_id) ],
205
                    lines  => [ Koha::Account::Lines->find($accountlines_id) ],
206
                    type   => 'writeoff',
206
                    type   => 'writeoff',
207
                    note   => $payment_note,
207
                    note   => $payment_note,
208
                    library_id => $branch,
208
                    library_id => $branch,
(-)a/opac/opac-memberentry.pl (-1 / +1 lines)
Lines 299-305 elsif ( $action eq 'edit' ) { #Display logged in borrower's data Link Here
299
299
300
    $template->param(
300
    $template->param(
301
        borrower  => $borrower,
301
        borrower  => $borrower,
302
        guarantor => scalar Koha::Patrons->find($borrowernumber)->guarantor(),
302
        guarantor => Koha::Patrons->find($borrowernumber)->guarantor(),
303
        hidden => GetHiddenFields( $mandatory, 'modification' ),
303
        hidden => GetHiddenFields( $mandatory, 'modification' ),
304
        csrf_token => Koha::Token->new->generate_csrf({
304
        csrf_token => Koha::Token->new->generate_csrf({
305
            session_id => scalar $cgi->cookie('CGISESSID'),
305
            session_id => scalar $cgi->cookie('CGISESSID'),
(-)a/opac/opac-user.pl (-1 / +1 lines)
Lines 356-362 if ( C4::Context->preference('AllowPatronToSetCheckoutsVisibilityForGuarantor' Link Here
356
}
356
}
357
357
358
$template->param(
358
$template->param(
359
    borrower                 => scalar Koha::Patrons->find($borrowernumber),
359
    borrower                 => Koha::Patrons->find($borrowernumber),
360
    patron_messages          => $patron_messages,
360
    patron_messages          => $patron_messages,
361
    opacnote                 => $borr->{opacnote},
361
    opacnote                 => $borr->{opacnote},
362
    patronupdate             => $patronupdate,
362
    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