Bugzilla – Attachment 123105 Details for
Bug 28739
Objects in notices should restrict the methods that can be called
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[FOR DISCUSSION] Bug 28739: Add Koha::Object->read_only
FOR-DISCUSSION-Bug-28739-Add-KohaObject-readonly.patch (text/plain), 1.75 KB, created by
Kyle M Hall (khall)
on 2021-07-23 12:16:09 UTC
(
hide
)
Description:
[FOR DISCUSSION] Bug 28739: Add Koha::Object->read_only
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-07-23 12:16:09 UTC
Size:
1.75 KB
patch
obsolete
>From 05fd6eae35d95a670dce9d042477bddb39974111 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 23 Jul 2021 08:14:10 -0400 >Subject: [PATCH] [FOR DISCUSSION] Bug 28739: Add Koha::Object->read_only > >--- > Koha/Object.pm | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index 8e5892ceec..7ffd8ff2ed 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -378,6 +378,18 @@ sub add_message { > my ( $self, $params ) = @_; > > push @{ $self->{_messages} }, Koha::Object::Message->new($params); >+} >+ >+=head3 $object->read_only(); >+ >+Set the object as read_only, only getter methods will be allowed >+ >+=cut >+ >+sub read_only { >+ my ($self) = @_; >+ >+ $self->{_read_only} = 1; > > return $self; > } >@@ -814,6 +826,8 @@ sub AUTOLOAD { > # Using direct setter/getter like $item->barcode() or $item->barcode($barcode); > if ( grep { $_ eq $method } @columns ) { > if ( @_ ) { >+ die "Setter method $method called on read-only object" >+ if $self->{_read_only}; > $self->_result()->set_column( $method, @_ ); > return $self; > } else { >@@ -822,6 +836,9 @@ sub AUTOLOAD { > } > } > >+ die "Cannot call method $method on a read-only object" >+ if $self->{_read_only}; >+ > my @known_methods = qw( is_changed id in_storage get_column discard_changes make_column_dirty ); > > Koha::Exceptions::Object::MethodNotCoveredByTests->throw( >@@ -829,7 +846,6 @@ sub AUTOLOAD { > show_trace => 1 > ) unless grep { $_ eq $method } @known_methods; > >- > if ( $method eq 'update' ) { > return $self if ( ( caller() )[0] eq 'Template::Document' ); > } >-- >2.30.1 (Apple Git-130)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28739
:
123104
|
123105
|
126190
|
130482
|
135236
|
136804