Bugzilla – Attachment 123104 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]
Bug 28739: Ignore store, update and delete when called from Template Toolkit
Bug-28739-Ignore-store-update-and-delete-when-call.patch (text/plain), 2.14 KB, created by
Kyle M Hall (khall)
on 2021-07-23 12:15:43 UTC
(
hide
)
Description:
Bug 28739: Ignore store, update and delete when called from Template Toolkit
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-07-23 12:15:43 UTC
Size:
2.14 KB
patch
obsolete
>From 47fa162822d3ac693e244f1a6f9d0045570a65f1 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 23 Jul 2021 08:09:04 -0400 >Subject: [PATCH] Bug 28739: Ignore store, update and delete when called from > Template Toolkit > >--- > Koha/Object.pm | 8 ++++++++ > Koha/Objects.pm | 5 ++++- > 2 files changed, 12 insertions(+), 1 deletion(-) > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index 08602da67f..8e5892ceec 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -125,6 +125,8 @@ Returns: > sub store { > my ($self) = @_; > >+ return $self if ( ( caller() )[0] eq 'Template::Document' ); >+ > my $columns_info = $self->_result->result_source->columns_info; > > # Handle not null and default values for integers and dates >@@ -230,6 +232,8 @@ Returns: > sub delete { > my ($self) = @_; > >+ return $self if ( ( caller() )[0] eq 'Template::Document' ); >+ > my $deleted = $self->_result()->delete; > if ( ref $deleted ) { > my $object_class = Koha::Object::_get_object_class( $self->_result->result_class ); >@@ -826,6 +830,10 @@ sub AUTOLOAD { > ) unless grep { $_ eq $method } @known_methods; > > >+ if ( $method eq 'update' ) { >+ return $self if ( ( caller() )[0] eq 'Template::Document' ); >+ } >+ > my $r = eval { $self->_result->$method(@_) }; > if ( $@ ) { > Koha::Exceptions::Object->throw( ref($self) . "::$method generated this error: " . $@ ); >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index 3ee0a55742..83abef97cd 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -589,7 +589,6 @@ sub AUTOLOAD { > my $method = our $AUTOLOAD; > $method =~ s/.*:://; > >- > unless ( grep { $_ eq $method } @known_methods ) { > my $class = ref($self) ? ref($self) : $self; > Koha::Exceptions::Object::MethodNotCoveredByTests->throw( >@@ -598,6 +597,10 @@ sub AUTOLOAD { > ); > } > >+ if ( $method eq 'update' || $method eq 'delete' ) { >+ return $self if ( ( caller() )[0] eq 'Template::Document' ); >+ } >+ > my $r = eval { $self->_resultset->$method(@params) }; > if ( $@ ) { > carp "No method $method found for " . ref($self) . " " . $@; >-- >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