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

(-)a/Koha/Object.pm (-10 / +14 lines)
Lines 900-906 The autoload method is used only to get and set values for an objects properties Link Here
900
=cut
900
=cut
901
901
902
sub AUTOLOAD {
902
sub AUTOLOAD {
903
    my $self = shift;
903
    my ($self) = @_;
904
904
905
    my $method = our $AUTOLOAD;
905
    my $method = our $AUTOLOAD;
906
    $method =~ s/.*://;
906
    $method =~ s/.*://;
Lines 908-920 sub AUTOLOAD { Link Here
908
    my @columns = @{$self->_columns()};
908
    my @columns = @{$self->_columns()};
909
    # Using direct setter/getter like $item->barcode() or $item->barcode($barcode);
909
    # Using direct setter/getter like $item->barcode() or $item->barcode($barcode);
910
    if ( grep { $_ eq $method } @columns ) {
910
    if ( grep { $_ eq $method } @columns ) {
911
        if ( @_ ) {
911
        no strict 'refs';
912
            $self->_result()->set_column( $method, @_ );
912
        *{$AUTOLOAD} = sub {
913
            return $self;
913
            my $self = shift;
914
        } else {
914
            if ( @_ ) {
915
            my $value = $self->_result()->get_column( $method );
915
                $self->_result()->set_column( $method, @_);
916
            return $value;
916
                return $self;
917
        }
917
            } else {
918
                return $self->_result()->get_column( $method );
919
            }
920
        };
921
        goto &{$AUTOLOAD};
918
    }
922
    }
919
923
920
    my @known_methods = qw( is_changed id in_storage get_column discard_changes make_column_dirty );
924
    my @known_methods = qw( is_changed id in_storage get_column discard_changes make_column_dirty );
Lines 924-930 sub AUTOLOAD { Link Here
924
        show_trace => 1
928
        show_trace => 1
925
    ) unless grep { $_ eq $method } @known_methods;
929
    ) unless grep { $_ eq $method } @known_methods;
926
930
927
931
    # Remove $self so that @_ now contain arguments only
932
    shift;
928
    my $r = eval { $self->_result->$method(@_) };
933
    my $r = eval { $self->_result->$method(@_) };
929
    if ( $@ ) {
934
    if ( $@ ) {
930
        Koha::Exceptions::Object->throw( ref($self) . "::$method generated this error: " . $@ );
935
        Koha::Exceptions::Object->throw( ref($self) . "::$method generated this error: " . $@ );
931
- 

Return to bug 33745