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

(-)a/C4/Reserves.pm (-1 / +1 lines)
Lines 797-803 sub CheckReserves { Link Here
797
                    next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $patron->branchcode));
797
                    next if (($branchitemrule->{'holdallowed'} == 1) && ($branch ne $patron->branchcode));
798
                    my $hold_fulfillment_policy = $branchitemrule->{hold_fulfillment_policy};
798
                    my $hold_fulfillment_policy = $branchitemrule->{hold_fulfillment_policy};
799
                    next if ( ($branchitemrule->{hold_fulfillment_policy} ne 'any') && ($res->{branchcode} ne $item->$hold_fulfillment_policy) );
799
                    next if ( ($branchitemrule->{hold_fulfillment_policy} ne 'any') && ($res->{branchcode} ne $item->$hold_fulfillment_policy) );
800
                    next unless $item->can_be_transferred( { to => scalar Koha::Libraries->find( $res->{branchcode} ) } );
800
                    next unless $item->can_be_transferred( { to => Koha::Libraries->find( $res->{branchcode} ) } );
801
                    $priority = $res->{'priority'};
801
                    $priority = $res->{'priority'};
802
                    $highest  = $res;
802
                    $highest  = $res;
803
                    last if $local_hold_match;
803
                    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 61-67 sub cancel { Link Here
61
61
62
sub club {
62
sub club {
63
    my ( $self ) = @_;
63
    my ( $self ) = @_;
64
    return scalar Koha::Clubs->find( $self->club_id() );
64
    return Koha::Clubs->find( $self->club_id() );
65
}
65
}
66
66
67
=head3 patron
67
=head3 patron
Lines 70-76 sub club { Link Here
70
70
71
sub patron {
71
sub patron {
72
    my ( $self ) = @_;
72
    my ( $self ) = @_;
73
    return scalar Koha::Patrons->find( $self->borrowernumber() );
73
    return Koha::Patrons->find( $self->borrowernumber() );
74
}
74
}
75
75
76
=head3 is_canceled
76
=head3 is_canceled
(-)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 (-8 / +9 lines)
Lines 76-81 Similar to DBIx::Class::ResultSet->find this method accepts: Link Here
76
Strictly speaking, columns_values should only refer to columns under an
76
Strictly speaking, columns_values should only refer to columns under an
77
unique constraint.
77
unique constraint.
78
78
79
It returns undef if no results were found
80
79
my $object = Koha::Objects->find( { col1 => $val1, col2 => $val2 } );
81
my $object = Koha::Objects->find( { col1 => $val1, col2 => $val2 } );
80
my $object = Koha::Objects->find( $id );
82
my $object = Koha::Objects->find( $id );
81
my $object = Koha::Objects->find( $idpart1, $idpart2, $attrs ); # composite PK
83
my $object = Koha::Objects->find( $idpart1, $idpart2, $attrs ); # composite PK
Lines 85-99 my $object = Koha::Objects->find( $idpart1, $idpart2, $attrs ); # composite PK Link Here
85
sub find {
87
sub find {
86
    my ( $self, @pars ) = @_;
88
    my ( $self, @pars ) = @_;
87
89
88
    croak 'Cannot use "->find" in list context' if wantarray;
90
    my $object;
89
90
    return if !@pars || none { defined($_) } @pars;
91
91
92
    my $result = $self->_resultset()->find( @pars );
92
    unless (!@pars || none { defined($_) } @pars) {
93
93
        my $result = $self->_resultset()->find(@pars);
94
    return unless $result;
94
        if ($result) {
95
95
            $object = $self->object_class()->_new_from_dbic($result);
96
    my $object = $self->object_class()->_new_from_dbic( $result );
96
        }
97
    }
97
98
98
    return $object;
99
    return $object;
99
}
100
}
(-)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 309-315 if ($noreport) { Link Here
309
        }
309
        }
310
310
311
        push @overduedata, {
311
        push @overduedata, {
312
            patron                 => scalar Koha::Patrons->find( $data->{borrowernumber} ),
312
            patron                 => Koha::Patrons->find( $data->{borrowernumber} ),
313
            duedate                => $data->{date_due},
313
            duedate                => $data->{date_due},
314
            borrowernumber         => $data->{borrowernumber},
314
            borrowernumber         => $data->{borrowernumber},
315
            cardnumber             => $data->{cardnumber},
315
            cardnumber             => $data->{cardnumber},
(-)a/members/memberentry.pl (-1 / +1 lines)
Lines 791-797 $template->param( csrf_token => Link Here
791
791
792
# HouseboundModule data
792
# HouseboundModule data
793
$template->param(
793
$template->param(
794
    housebound_role  => scalar Koha::Patron::HouseboundRoles->find($borrowernumber),
794
    housebound_role  => Koha::Patron::HouseboundRoles->find($borrowernumber),
795
);
795
);
796
796
797
if(defined($data{'flags'})){
797
if(defined($data{'flags'})){
(-)a/members/pay.pl (-2 / +2 lines)
Lines 115-121 elsif ( $input->param('confirm_writeoff') ) { Link Here
115
        Koha::Account->new( { patron_id => $borrowernumber } )->pay(
115
        Koha::Account->new( { patron_id => $borrowernumber } )->pay(
116
            {
116
            {
117
                amount     => $amount,
117
                amount     => $amount,
118
                lines      => [ scalar Koha::Account::Lines->find($accountlines_id) ],
118
                lines      => [ Koha::Account::Lines->find($accountlines_id) ],
119
                type       => 'WRITEOFF',
119
                type       => 'WRITEOFF',
120
                note       => $payment_note,
120
                note       => $payment_note,
121
                interface  => C4::Context->interface,
121
                interface  => C4::Context->interface,
Lines 222-228 sub writeoff_all { Link Here
222
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
222
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
223
                {
223
                {
224
                    amount => $amount,
224
                    amount => $amount,
225
                    lines  => [ scalar Koha::Account::Lines->find($accountlines_id) ],
225
                    lines  => [ Koha::Account::Lines->find($accountlines_id) ],
226
                    type   => 'WRITEOFF',
226
                    type   => 'WRITEOFF',
227
                    note   => $payment_note,
227
                    note   => $payment_note,
228
                    interface  => C4::Context->interface,
228
                    interface  => C4::Context->interface,
(-)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