Bugzilla – Attachment 169244 Details for
Bug 37389
REST API queries joining on extended_attributes may cause severe performance issues
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37389: Move AUTOLOAD out of ILL::Request into Mixin
Bug-37389-Move-AUTOLOAD-out-of-ILLRequest-into-Mix.patch (text/plain), 3.84 KB, created by
Pedro Amorim
on 2024-07-19 16:02:51 UTC
(
hide
)
Description:
Bug 37389: Move AUTOLOAD out of ILL::Request into Mixin
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-07-19 16:02:51 UTC
Size:
3.84 KB
patch
obsolete
>From c3843b6756eef8581dac8b06516d0521276a8373 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Fri, 19 Jul 2024 15:49:18 +0000 >Subject: [PATCH] Bug 37389: Move AUTOLOAD out of ILL::Request into Mixin > >This AUTOLOAD is not being used, but we're keeping this as also being a result of this work if we ever want to support the following syntax in the code: >ill_request->extended_attributes_author; # and get the 'author' extended_attribute for the ill_request >--- > Koha/ILL/Request.pm | 31 ------------ > Koha/Object/Mixin/ExtendedAttributes.pm | 64 +++++++++++++++++++++++++ > 2 files changed, 64 insertions(+), 31 deletions(-) > create mode 100644 Koha/Object/Mixin/ExtendedAttributes.pm > >diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm >index d8b669fe95..9f6d8bdeba 100644 >--- a/Koha/ILL/Request.pm >+++ b/Koha/ILL/Request.pm >@@ -2220,37 +2220,6 @@ sub get_staff_table_actions { > return $ill_table_actions; > } > >-=head3 AUTOLOAD >- >-=cut >- >-our $AUTOLOAD; >- >-sub AUTOLOAD { >- my ($self) = @_; >- >- my $name = $AUTOLOAD; >- $name =~ s/.*:://; # Remove package name >- >- if ( $name =~ /^extended_attributes_(\w+)$/ ) { >- my $type = $1; >- >- # Define the method dynamically >- no strict 'refs'; >- *{$AUTOLOAD} = sub { >- my ($self) = @_; >- my $relation = 'extended_attributes_' . $type; >- my $rs = $self->_result->$relation; >- return Koha::ILL::Request::Attributes->_new_from_dbic($rs)->search; >- }; >- >- # Call the newly defined method >- return $self->$name(); >- } >- my $wt = 'SUPER::'.$name; >- return $self->$wt; >-} >- > sub get_column(){ > my ($self, $column_name) = @_; > return $self->_result->get_column($column_name); >diff --git a/Koha/Object/Mixin/ExtendedAttributes.pm b/Koha/Object/Mixin/ExtendedAttributes.pm >new file mode 100644 >index 0000000000..bb32429055 >--- /dev/null >+++ b/Koha/Object/Mixin/ExtendedAttributes.pm >@@ -0,0 +1,64 @@ >+package Koha::Object::Mixin::ExtendedAttributes; >+ >+# Copyright 2024 PTFS Europe Ltd >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+=head1 NAME >+ >+Koha::Object::Mixin::ExtendedAttributes >+ >+=head2 Class methods >+ >+ >+=head3 AUTOLOAD >+ >+=cut >+ >+our $AUTOLOAD; >+ >+# This class is not yet utilized, but we'll need it if we ever want to support this sort of syntax: >+# ill_request->extended_attributes_author; and get the 'author' extended_attributes from the ill_request >+# TODO: This needs to be abstracted in the future, currently only considering ILL >+ >+sub AUTOLOAD { >+ my ($self) = @_; >+ >+ my $name = $AUTOLOAD; >+ $name =~ s/.*:://; # Remove package name >+ >+ if ( $name =~ /^extended_attributes_(\w+)$/ ) { >+ my $type = $1; >+ >+ # Define the method dynamically >+ no strict 'refs'; >+ *{$AUTOLOAD} = sub { >+ my ($self) = @_; >+ my $relation = 'extended_attributes_' . $type; >+ my $rs = $self->_result->$relation; >+ return Koha::ILL::Request::Attributes->_new_from_dbic($rs)->search; >+ }; >+ >+ # Call the newly defined method >+ return $self->$name(); >+ } >+ my $wt = 'SUPER::' . $name; >+ return $self->$wt; >+} >+ >+1; >\ No newline at end of file >-- >2.34.1
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 37389
:
169130
|
169133
|
169140
|
169149
|
169159
|
169178
|
169185
|
169189
|
169191
|
169192
|
169234
|
169243
|
169244
|
169245
|
169246
|
169317
|
169318
|
169569
|
169570
|
169583
|
169584
|
169585
|
169586
|
169850
|
169851
|
169944
|
169945
|
169946
|
169954
|
169955
|
169956